Reverse proxy fixes.

Ylian Saint-Hilaire committed Aug 31, 2019 at 19:40 UTC 9bda4db66e1f3dd9daa1ec8d59362a490344800a
4 files changed +38 -34
meshrelay.js
+16 -16
@@ -48,8 +48,8 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
48
49 // Disconnect this agent
50 obj.close = function (arg) {
51 - if ((arg == 1) || (arg == null)) { try { ws.close(); parent.parent.debug('relay', 'Relay: Soft disconnect (' + cleanRemoteAddr(ws._socket.remoteAddress) + ')'); } catch (e) { console.log(e); } } // Soft close, close the websocket
52 - if (arg == 2) { try { ws._socket._parent.end(); parent.parent.debug('relay', 'Relay: Hard disconnect (' + cleanRemoteAddr(ws._socket.remoteAddress) + ')'); } catch (e) { console.log(e); } } // Hard close, close the TCP socket
51 + if ((arg == 1) || (arg == null)) { try { ws.close(); parent.parent.debug('relay', 'Relay: Soft disconnect (' + cleanRemoteAddr(req.ip) + ')'); } catch (e) { console.log(e); } } // Soft close, close the websocket
52 + if (arg == 2) { try { ws._socket._parent.end(); parent.parent.debug('relay', 'Relay: Hard disconnect (' + cleanRemoteAddr(req.ip) + ')'); } catch (e) { console.log(e); } } // Hard close, close the TCP socket
53
54 // Aggressive cleanup
55 delete obj.id;
@@ -143,7 +143,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
143 // Check that at least one connection is authenticated
144 if ((obj.authenticated != true) && (relayinfo.peer1.authenticated != true)) {
145 ws.close();
146 - parent.parent.debug('relay', 'Relay without-auth: ' + obj.id + ' (' + cleanRemoteAddr(ws._socket.remoteAddress) + ')');
146 + parent.parent.debug('relay', 'Relay without-auth: ' + obj.id + ' (' + cleanRemoteAddr(req.ip) + ')');
147 delete obj.id;
148 delete obj.ws;
149 delete obj.peer;
@@ -186,7 +186,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
186 try { relayinfo.peer1.ws.send('c'); } catch (ex) { }
187 } else {
188 // Write the recording file header
189 - var firstBlock = JSON.stringify({ magic: 'MeshCentralRelaySession', ver: 1, userid: sessionUser._id, username: sessionUser.name, sessionid: obj.id, ipaddr1: cleanRemoteAddr(ws._socket.remoteAddress), ipaddr2: cleanRemoteAddr(obj.peer.ws._socket.remoteAddress), time: new Date().toLocaleString(), protocol: req.query.p, nodeid: req.query.nodeid });
189 + var firstBlock = JSON.stringify({ magic: 'MeshCentralRelaySession', ver: 1, userid: sessionUser._id, username: sessionUser.name, sessionid: obj.id, ipaddr1: cleanRemoteAddr(req.ip), ipaddr2: cleanRemoteAddr(obj.peer.req.ip), time: new Date().toLocaleString(), protocol: req.query.p, nodeid: req.query.nodeid });
190 recordingEntry(fd, 1, ((req.query.browser) ? 2 : 0), firstBlock, function () {
191 relayinfo.peer1.ws.logfile = ws.logfile = { fd: fd, lock: false };
192 try { ws.send('cr'); } catch (ex) { } // Send connect to both peers, 'cr' indicates the session is being recorded.
@@ -200,7 +200,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
200 try { relayinfo.peer1.ws.send('c'); } catch (ex) { }
201 }
202
203 - parent.parent.debug('relay', 'Relay connected: ' + obj.id + ' (' + cleanRemoteAddr(ws._socket.remoteAddress) + ' --> ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ')');
203 + parent.parent.debug('relay', 'Relay connected: ' + obj.id + ' (' + cleanRemoteAddr(req.ip) + ' --> ' + cleanRemoteAddr(obj.peer.req.ip) + ')');
204
205 // Log the connection
206 if (sessionUser != null) {
@@ -208,13 +208,13 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
208 if (req.query.p == 1) { msg = 'Started terminal session'; }
209 else if (req.query.p == 2) { msg = 'Started desktop session'; }
210 else if (req.query.p == 5) { msg = 'Started file management session'; }
211 - var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: sessionUser._id, username: sessionUser.name, msg: msg + ' \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ' to ' + cleanRemoteAddr(ws._socket.remoteAddress), protocol: req.query.p, nodeid: req.query.nodeid };
211 + var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: sessionUser._id, username: sessionUser.name, msg: msg + ' \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.req.ip) + ' to ' + cleanRemoteAddr(req.ip), protocol: req.query.p, nodeid: req.query.nodeid };
212 parent.parent.DispatchEvent(['*', sessionUser._id], obj, event);
213 }
214 } else {
215 // Connected already, drop (TODO: maybe we should re-connect?)
216 ws.close();
217 - parent.parent.debug('relay', 'Relay duplicate: ' + obj.id + ' (' + cleanRemoteAddr(ws._socket.remoteAddress) + ')');
217 + parent.parent.debug('relay', 'Relay duplicate: ' + obj.id + ' (' + cleanRemoteAddr(req.ip) + ')');
218 delete obj.id;
219 delete obj.ws;
220 delete obj.peer;
@@ -224,7 +224,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
224 // Wait for other relay connection
225 ws._socket.pause(); // Hold traffic until the other connection
226 parent.wsrelays[obj.id] = { peer1: obj, state: 1, timeout: setTimeout(function () { closeBothSides(); }, 30000) };
227 - parent.parent.debug('relay', 'Relay holding: ' + obj.id + ' (' + cleanRemoteAddr(ws._socket.remoteAddress) + ') ' + (obj.authenticated ? 'Authenticated' : ''));
227 + parent.parent.debug('relay', 'Relay holding: ' + obj.id + ' (' + cleanRemoteAddr(req.ip) + ') ' + (obj.authenticated ? 'Authenticated' : ''));
228
229 // Check if a peer server has this connection
230 if (parent.parent.multiServer != null) {
@@ -267,7 +267,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
267 ws.on('error', function (err) {
268 parent.relaySessionErrorCount++;
269 if (obj.relaySessionCounted) { parent.relaySessionCount--; delete obj.relaySessionCounted; }
270 - console.log('Relay error from ' + cleanRemoteAddr(ws._socket.remoteAddress) + ', ' + err.toString().split('\r')[0] + '.');
270 + console.log('Relay error from ' + cleanRemoteAddr(req.ip) + ', ' + err.toString().split('\r')[0] + '.');
271 closeBothSides();
272 });
273
@@ -290,7 +290,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
290
291 // Disconnect the peer
292 try { if (peer.relaySessionCounted) { parent.relaySessionCount--; delete peer.relaySessionCounted; } } catch (ex) { console.log(ex); }
293 - parent.parent.debug('relay', 'Relay disconnect: ' + obj.id + ' (' + cleanRemoteAddr(ws._socket.remoteAddress) + ' --> ' + cleanRemoteAddr(peer.ws._socket.remoteAddress) + ')');
293 + parent.parent.debug('relay', 'Relay disconnect: ' + obj.id + ' (' + cleanRemoteAddr(req.ip) + ' --> ' + cleanRemoteAddr(peer.req.ip) + ')');
294 try { peer.ws.close(); } catch (e) { } // Soft disconnect
295 try { peer.ws._socket._parent.end(); } catch (e) { } // Hard disconnect
296
@@ -301,10 +301,10 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
301 else if (req.query.p == 2) { msg = 'Ended desktop session'; }
302 else if (req.query.p == 5) { msg = 'Ended file management session'; }
303 if (user) {
304 - var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: user._id, username: parent.users[user._id].name, msg: msg + ' \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ' to ' + cleanRemoteAddr(ws._socket.remoteAddress) + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)', protocol: req.query.p, nodeid: req.query.nodeid };
304 + var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: user._id, username: parent.users[user._id].name, msg: msg + ' \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.req.ip) + ' to ' + cleanRemoteAddr(req.ip) + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)', protocol: req.query.p, nodeid: req.query.nodeid };
305 parent.parent.DispatchEvent(['*', user._id], obj, event);
306 } else if (peer.user) {
307 - var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: peer.user._id, username: parent.users[peer.user._id].name, msg: msg + ' \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.ws._socket.remoteAddress) + ' to ' + cleanRemoteAddr(ws._socket.remoteAddress) + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)', protocol: req.query.p, nodeid: req.query.nodeid };
307 + var event = { etype: 'relay', action: 'relaylog', domain: domain.id, userid: peer.user._id, username: parent.users[peer.user._id].name, msg: msg + ' \"' + obj.id + '\" from ' + cleanRemoteAddr(obj.peer.req.ip) + ' to ' + cleanRemoteAddr(req.ip) + ', ' + Math.floor((Date.now() - ws.time) / 1000) + ' second(s)', protocol: req.query.p, nodeid: req.query.nodeid };
308 parent.parent.DispatchEvent(['*', peer.user._id], obj, event);
309 }
310 }
@@ -314,7 +314,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
314 delete peer.ws;
315 delete peer.peer;
316 } else {
317 - parent.parent.debug('relay', 'Relay disconnect: ' + obj.id + ' (' + cleanRemoteAddr(ws._socket.remoteAddress) + ')');
317 + parent.parent.debug('relay', 'Relay disconnect: ' + obj.id + ' (' + cleanRemoteAddr(req.ip) + ')');
318 }
319 try { ws.close(); } catch (ex) { }
320 delete parent.wsrelays[obj.id];
@@ -371,7 +371,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
371 if (obj.id == undefined) { obj.id = ('' + Math.random()).substring(2); } // If there is no connection id, generate one.
372 var command = { nodeid: cookie.nodeid, action: 'msg', type: 'tunnel', value: '*/meshrelay.ashx?id=' + obj.id, tcpport: cookie.tcpport, tcpaddr: cookie.tcpaddr };
373 parent.parent.debug('relay', 'Relay: Sending agent tunnel command: ' + JSON.stringify(command));
374 - if (obj.sendAgentMessage(command, user._id, cookie.domainid) == false) { delete obj.id; parent.parent.debug('relay', 'Relay: Unable to contact this agent (' + cleanRemoteAddr(ws._socket.remoteAddress) + ')'); }
374 + if (obj.sendAgentMessage(command, user._id, cookie.domainid) == false) { delete obj.id; parent.parent.debug('relay', 'Relay: Unable to contact this agent (' + cleanRemoteAddr(req.ip) + ')'); }
375 performRelay();
376 });
377 return obj;
@@ -391,11 +391,11 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
391 if (req.query.tcpport != null) {
392 var command = { nodeid: req.query.nodeid, action: 'msg', type: 'tunnel', value: '*/meshrelay.ashx?id=' + obj.id, tcpport: req.query.tcpport, tcpaddr: ((req.query.tcpaddr == null) ? '127.0.0.1' : req.query.tcpaddr) };
393 parent.parent.debug('relay', 'Relay: Sending agent TCP tunnel command: ' + JSON.stringify(command));
394 - if (obj.sendAgentMessage(command, user._id, domain.id) == false) { delete obj.id; parent.parent.debug('relay', 'Relay: Unable to contact this agent (' + cleanRemoteAddr(ws._socket.remoteAddress) + ')'); }
394 + if (obj.sendAgentMessage(command, user._id, domain.id) == false) { delete obj.id; parent.parent.debug('relay', 'Relay: Unable to contact this agent (' + cleanRemoteAddr(req.ip) + ')'); }
395 } else if (req.query.udpport != null) {
396 var command = { nodeid: req.query.nodeid, action: 'msg', type: 'tunnel', value: '*/meshrelay.ashx?id=' + obj.id, udpport: req.query.udpport, udpaddr: ((req.query.udpaddr == null) ? '127.0.0.1' : req.query.udpaddr) };
397 parent.parent.debug('relay', 'Relay: Sending agent UDP tunnel command: ' + JSON.stringify(command));
398 - if (obj.sendAgentMessage(command, user._id, domain.id) == false) { delete obj.id; parent.parent.debug('relay', 'Relay: Unable to contact this agent (' + cleanRemoteAddr(ws._socket.remoteAddress) + ')'); }
398 + if (obj.sendAgentMessage(command, user._id, domain.id) == false) { delete obj.id; parent.parent.debug('relay', 'Relay: Unable to contact this agent (' + cleanRemoteAddr(req.ip) + ')'); }
399 }
400 performRelay();
401 });
meshscanner.js
+7 -4
@@ -137,16 +137,19 @@ module.exports.CreateMeshScanner = function (parent) {
137 try { info = obj.parent.config.domains[''].title2; } catch (ex) { }
138 try { info = obj.parent.args.localdiscovery.info; } catch (ex) { }
139
140 + // Figure out the correct websocket port
141 + var port = (parent.args.aliasport)?parent.args.aliasport:parent.args.port;
142 +
143 // Build the IPv4 response
141 - var url = (parent.args.notls ? 'ws' : 'wss') + '://%s:' + parent.args.port + '/agent.ashx';
144 + var url = (parent.args.notls ? 'ws' : 'wss') + '://%s:' + port + '/agent.ashx';
145 obj.multicastPacket4 = Buffer.from("MeshCentral2|" + obj.agentCertificateHashHex + '|' + url, 'ascii');
143 - if (parent.certificates.CommonName.indexOf('.') != -1) { url = (parent.args.notls ? 'ws' : 'wss') + '://' + parent.certificates.CommonName + ':' + parent.args.port + '/agent.ashx'; }
146 + if (parent.certificates.CommonName.indexOf('.') != -1) { url = (parent.args.notls ? 'ws' : 'wss') + '://' + parent.certificates.CommonName + ':' + port + '/agent.ashx'; }
147 obj.multicastPacket4x = Buffer.from("MeshCentral2|" + obj.agentCertificateHashHex + '|' + url + '|' + name + '|' + info, 'ascii');
148
149 // Build the IPv6 response
147 - url = (parent.args.notls ? 'ws' : 'wss') + '://[%s]:' + parent.args.port + '/agent.ashx';
150 + url = (parent.args.notls ? 'ws' : 'wss') + '://[%s]:' + port + '/agent.ashx';
151 obj.multicastPacket6 = Buffer.from("MeshCentral2|" + obj.agentCertificateHashHex + '|' + url, 'ascii');
149 - if (parent.certificates.CommonName.indexOf('.') != -1) { url = (parent.args.notls ? 'ws' : 'wss') + '://' + parent.certificates.CommonName + ':' + parent.args.port + '/agent.ashx'; }
152 + if (parent.certificates.CommonName.indexOf('.') != -1) { url = (parent.args.notls ? 'ws' : 'wss') + '://' + parent.certificates.CommonName + ':' + port + '/agent.ashx'; }
153 obj.multicastPacket6x = Buffer.from("MeshCentral2|" + obj.agentCertificateHashHex + '|' + url + '|' + name + '|' + info, 'ascii');
154
155 setupServers();
meshuser.js
+7 -6
@@ -51,6 +51,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
51 // Send a message to the user
52 //obj.send = function (data) { try { if (typeof data == 'string') { ws.send(Buffer.from(data, 'binary')); } else { ws.send(data); } } catch (e) { } }
53
54 + // Clean a IPv6 address that encodes a IPv4 address
55 + function cleanRemoteAddr(addr) { if (addr.startsWith('::ffff:')) { return addr.substring(7); } else { return addr; } }
56 +
57 // Disconnect this user
58 obj.close = function (arg) {
59 if ((arg == 1) || (arg == null)) { try { ws.close(); parent.parent.debug('user', 'Soft disconnect'); } catch (e) { console.log(e); } } // Soft close, close the websocket
@@ -142,7 +145,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
145 if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
146 command.username = user.name; // Add user name
147 command.userid = user._id; // Add user id
145 - command.remoteaddr = (req.ip.startsWith('::ffff:')) ? (req.ip.substring(7)) : req.ip; // User's IP address
148 + command.remoteaddr = cleanRemoteAddr(req.ip); // User's IP address
149 delete command.nodeid; // Remove the nodeid since it's implied
150 try { agent.send(JSON.stringify(command)); } catch (ex) { }
151 }
@@ -160,7 +163,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
163 if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
164 command.username = user.name; // Add user name
165 command.userid = user._id; // Add user id
163 - command.remoteaddr = (req.ip.startsWith('::ffff:')) ? (req.ip.substring(7)) : req.ip; // User's IP address
166 + command.remoteaddr = cleanRemoteAddr(req.ip); // User's IP address
167 parent.parent.multiServer.DispatchMessageSingleServer(command, routing.serverid);
168 }
169 }
@@ -765,8 +768,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
768 case 'relays': {
769 for (var i in parent.wsrelays) {
770 r += 'id: ' + i + ', state: ' + parent.wsrelays[i].state;
768 - if (parent.wsrelays[i].peer1 != null) { r += ', peer1: ' + cleanRemoteAddr(parent.wsrelays[i].peer1.ws._socket.remoteAddress); }
769 - if (parent.wsrelays[i].peer2 != null) { r += ', peer2: ' + cleanRemoteAddr(parent.wsrelays[i].peer2.ws._socket.remoteAddress); }
771 + if (parent.wsrelays[i].peer1 != null) { r += ', peer1: ' + cleanRemoteAddr(parent.wsrelays[i].peer1.req.ip); }
772 + if (parent.wsrelays[i].peer2 != null) { r += ', peer2: ' + cleanRemoteAddr(parent.wsrelays[i].peer2.req.ip); }
773 r += '<br />';
774 }
775 if (r == '') { r = 'No relays.'; }
@@ -2863,8 +2866,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
2866 // Return true if at least one element of arr2 is in arr1
2867 function findOne(arr1, arr2) { if ((arr1 == null) || (arr2 == null)) return false; return arr2.some(function (v) { return arr1.indexOf(v) >= 0; }); };
2868
2866 - // Clean a IPv6 address that encodes a IPv4 address
2867 - function cleanRemoteAddr(addr) { if (addr.startsWith('::ffff:')) { return addr.substring(7); } else { return addr; } }
2869 function getRandomPassword() { return Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64').split('/').join('@'); }
2870
2871 return obj;
webserver.js
+8 -8
@@ -2119,7 +2119,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2119 var fd = obj.fs.openSync(recFullFilename, 'w');
2120 if (fd != null) {
2121 // Write the recording file header
2122 - var firstBlock = JSON.stringify({ magic: 'MeshCentralRelaySession', ver: 1, userid: user._id, username: user.name, ipaddr: cleanRemoteAddr(ws._socket.remoteAddress), nodeid: node._id, intelamt: true, protocol: (req.query.p == 2) ? 101 : 100, time: new Date().toLocaleString() })
2122 + var firstBlock = JSON.stringify({ magic: 'MeshCentralRelaySession', ver: 1, userid: user._id, username: user.name, ipaddr: cleanRemoteAddr(req.ip), nodeid: node._id, intelamt: true, protocol: (req.query.p == 2) ? 101 : 100, time: new Date().toLocaleString() })
2123 recordingEntry(fd, 1, 0, firstBlock, function () { });
2124 ws.logfile = { fd: fd, lock: false };
2125 if (req.query.p == 2) { ws.send(Buffer.from(String.fromCharCode(0xF0), 'binary')); } // Intel AMT Redirection: Indicate the session is being recorded
@@ -2213,7 +2213,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2213
2214 // If error, close the associated TCP connection.
2215 ws.on('error', function (err) {
2216 - console.log('CIRA server websocket error from ' + ws._socket.remoteAddress + ', ' + err.toString().split('\r')[0] + '.');
2216 + console.log('CIRA server websocket error from ' + cleanRemoteAddr(req.ip) + ', ' + err.toString().split('\r')[0] + '.');
2217 parent.debug('webrelay', 'Websocket relay closed on error.');
2218 if (ws.forwardclient && ws.forwardclient.close) { ws.forwardclient.close(); } // TODO: If TLS is used, we need to close the socket that is wrapped by TLS
2219
@@ -2306,8 +2306,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2306
2307 // If error, close the associated TCP connection.
2308 ws.on('error', function (err) {
2309 - console.log('Error with relay web socket connection from ' + ws._socket.remoteAddress + ', ' + err.toString().split('\r')[0] + '.');
2310 - parent.debug('webrelay', 'Error with relay web socket connection from ' + ws._socket.remoteAddress + '.');
2309 + console.log('Error with relay web socket connection from ' + cleanRemoteAddr(req.ip) + ', ' + err.toString().split('\r')[0] + '.');
2310 + parent.debug('webrelay', 'Error with relay web socket connection from ' + cleanRemoteAddr(req.ip) + '.');
2311 if (ws.forwardclient) { try { ws.forwardclient.destroy(); } catch (e) { } }
2312
2313 // Close the recording file
@@ -2419,7 +2419,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2419 if (mesh.mtype != 1) { ws.send(JSON.stringify({ errorText: 'Invalid device group type' })); ws.close(); return; }
2420
2421 // Fetch the remote IP:Port for logging
2422 - ws.remoteaddr = (req.ip.startsWith('::ffff:')) ? (req.ip.substring(7)) : req.ip;
2422 + ws.remoteaddr = cleanRemoteAddr(req.ip);
2423 ws.remoteaddrport = ws.remoteaddr + ':' + ws._socket.remotePort;
2424
2425 // When data is received from the web socket, echo it back
@@ -2606,7 +2606,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2606 });
2607
2608 // If error, do nothing.
2609 - ws.on('error', function (err) { console.log('Echo server error from ' + ws._socket.remoteAddress + ', ' + err.toString().split('\r')[0] + '.'); });
2609 + ws.on('error', function (err) { console.log('Echo server error from ' + cleanRemoteAddr(req.ip) + ', ' + err.toString().split('\r')[0] + '.'); });
2610
2611 // If closed, do nothing
2612 ws.on('close', function (req) { });
@@ -3233,8 +3233,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3233 // Receive mesh agent connections
3234 obj.app.ws(url + 'agent.ashx', function (ws, req) {
3235 var domain = checkAgentIpAddress(ws, req);
3236 - if (domain == null) { parent.debug('web', 'Got agent connection from blocked IP address ' + ws._socket.remoteAddress + ', holding.'); return; }
3237 - // console.log('Agent connect: ' + ws._socket.remoteAddress);
3236 + if (domain == null) { parent.debug('web', 'Got agent connection from blocked IP address ' + cleanRemoteAddr(req.ip) + ', holding.'); return; }
3237 + //console.log('Agent connect: ' + cleanRemoteAddr(req.ip));
3238 try { obj.meshAgentHandler.CreateMeshAgent(obj, obj.db, ws, req, obj.args, domain); } catch (e) { console.log(e); }
3239 });
3240