mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Fixed issue with farmhash and undefined ip
This commit is contained in:
		@@ -4,7 +4,7 @@ path = require('path'),
 | 
				
			|||||||
//publicPath = path.join(__dirname, 'public'),
 | 
					//publicPath = path.join(__dirname, 'public'),
 | 
				
			||||||
http = require('http'),
 | 
					http = require('http'),
 | 
				
			||||||
port = 8080,
 | 
					port = 8080,
 | 
				
			||||||
farmhash = require('farmhash'),
 | 
					//farmhash = require('farmhash'),
 | 
				
			||||||
num_processes = require('os').cpus().length;
 | 
					num_processes = require('os').cpus().length;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
publicPath = path.join(__dirname, 'public');
 | 
					publicPath = path.join(__dirname, 'public');
 | 
				
			||||||
@@ -47,7 +47,15 @@ function startClustered(redis_enabled) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var worker_index = function(ip, len) {
 | 
					        var worker_index = function(ip, len) {
 | 
				
			||||||
            return farmhash.fingerprint32(ip) % len;
 | 
					            //console.log(ip);
 | 
				
			||||||
 | 
					            var s = '';
 | 
				
			||||||
 | 
					            for (var i = 0, _len = ip.length; i < _len; i++) {
 | 
				
			||||||
 | 
					                if(!isNaN(ip[i])) {
 | 
				
			||||||
 | 
					                    s += ip[i];
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return Number(s)%len;
 | 
				
			||||||
 | 
					            //eturn farmhash.fingerprint32(ip) % len;
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var server = net.createServer({ pauseOnConnect: true }, function(connection, a) {
 | 
					        var server = net.createServer({ pauseOnConnect: true }, function(connection, a) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user