Update existing networks with ip and hostmask if null
This commit is contained in:
parent
4078abb085
commit
00548e65d7
@ -463,7 +463,31 @@ Client.prototype.quit = function() {
|
||||
};
|
||||
|
||||
Client.prototype.clientAttach = function(socketId) {
|
||||
this.attachedClients[socketId] = this.lastActiveChannel;
|
||||
var client = this;
|
||||
var save = false;
|
||||
|
||||
client.attachedClients[socketId] = client.lastActiveChannel;
|
||||
|
||||
// Update old networks to store ip and hostmask
|
||||
client.networks.forEach(network => {
|
||||
if (!network.ip) {
|
||||
save = true;
|
||||
network.ip = (client.config && client.config.ip) || client.ip;
|
||||
}
|
||||
|
||||
if (!network.hostname) {
|
||||
var hostmask = (client.config && client.config.hostname) || client.hostname;
|
||||
|
||||
if (hostmask) {
|
||||
save = true;
|
||||
network.hostmask = hostmask;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (save) {
|
||||
client.save();
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype.clientDetach = function(socketId) {
|
||||
|
@ -143,15 +143,13 @@ function init(socket, client) {
|
||||
} else {
|
||||
socket.emit("authorized");
|
||||
|
||||
client.ip = getClientIp(socket.request);
|
||||
|
||||
socket.on("disconnect", function() {
|
||||
client.clientDetach(socket.id);
|
||||
});
|
||||
client.clientAttach(socket.id);
|
||||
|
||||
if (!client.ip) {
|
||||
client.ip = getClientIp(socket.request);
|
||||
}
|
||||
|
||||
socket.on(
|
||||
"input",
|
||||
function(data) {
|
||||
|
Loading…
Reference in New Issue
Block a user