1
0
mirror of synced 2024-11-30 20:54:31 +01:00

fix pref_ip not working issue

This commit is contained in:
xpeng 2022-08-25 00:22:41 +02:00
parent 57bc85c0dc
commit 524c3994de

View File

@ -14,10 +14,10 @@ var occupancy = [0, 0, 0, 0];
var suffixes = [11, 12, 13, 14];
var clients = {};
function allocateClient(req) {
function allocateClient(msg) {
var slot;
if (req.pref_ip) {
slot = suffixes.indexOf(req.pref_ip);
if (msg.pref_ip) {
slot = suffixes.indexOf(msg.pref_ip);
if (slot >= 0 && !occupancy[slot]) {
occupancy[slot] = 1;
return slot;
@ -81,7 +81,7 @@ function registerUser(conn, req, msg) {
}
// Allocate User
var slot = allocateClient(req);
var slot = allocateClient(msg);
var realip = req.socket.remoteAddress;
if (slot < 0) {
console.log('Dropping ' + realip + ' due to no party vacancy');