diff --git a/meshrelay.js b/meshrelay.js index 1cf73853..9a6f87ed 100644 --- a/meshrelay.js +++ b/meshrelay.js @@ -177,19 +177,25 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie } } - ws.flushSink = function () { try { ws._socket.resume(); } catch (e) { } }; + ws.flushSink = function () { try { ws._socket.resume(); } catch (ex) { console.log(ex); } }; // When data is received from the mesh relay web socket ws.on('message', function (data) { //console.log(typeof data, data.length); if (this.peer != null) { //if (typeof data == 'string') { console.log('Relay: ' + data); } else { console.log('Relay:' + data.length + ' byte(s)'); } - try { this._socket.pause(); this.peer.send(data, ws.flushSink); } catch (e) { } + try { + this._socket.pause(); + this.peer.send(data, ws.flushSink); + } catch (ex) { console.log(ex); } } }); // If error, do nothing - ws.on('error', function (err) { /*console.log('Relay Error: ' + err);*/ }); + ws.on('error', function (err) { + console.log('Relay Error', err); + obj.close(); + }); // If the mesh relay web socket is closed ws.on('close', function (req) { diff --git a/package.json b/package.json index f8e5aa37..071f6541 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.2.4-e", + "version": "0.2.4-g", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.application b/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.application similarity index 85% rename from public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.application rename to public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.application index 4d9757a0..de8e7b14 100644 --- a/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.application +++ b/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.application @@ -1,20 +1,20 @@  - + - - + + - OrVnTQLTKIxVLZNkTlIIvRGSS1WhevCMECD0a58kSYI= + WOFMexmFiT1cRB5ZPY6zmeQ7x/Cbx//7QyPjwnjKGnA= diff --git a/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.exe.config.deploy b/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.exe.config.deploy similarity index 100% rename from public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.exe.config.deploy rename to public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.exe.config.deploy diff --git a/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.exe.deploy b/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.exe.deploy similarity index 83% rename from public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.exe.deploy rename to public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.exe.deploy index 128e5646..866545d4 100644 Binary files a/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.exe.deploy and b/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.exe.deploy differ diff --git a/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.exe.manifest b/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.exe.manifest similarity index 90% rename from public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.exe.manifest rename to public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.exe.manifest index 36d5630b..0b27acb2 100644 --- a/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.exe.manifest +++ b/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.exe.manifest @@ -1,10 +1,10 @@  - + - + @@ -43,14 +43,14 @@ - - + + - 06I3GLTLWQ3HjlpCbxpboVtNzeTJZ6nWgSqw191sAuE= + e/EE2UyAOSDkWCqJcDJPIiu7cOLRXJszqGGnayICf5I= diff --git a/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.ico.deploy b/public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.ico.deploy similarity index 100% rename from public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_19/MeshMiniRouter.ico.deploy rename to public/clickonce/minirouter/Application Files/MeshMiniRouter_2_0_0_22/MeshMiniRouter.ico.deploy diff --git a/public/clickonce/minirouter/MeshMiniRouter.application b/public/clickonce/minirouter/MeshMiniRouter.application index 4d9757a0..de8e7b14 100644 --- a/public/clickonce/minirouter/MeshMiniRouter.application +++ b/public/clickonce/minirouter/MeshMiniRouter.application @@ -1,20 +1,20 @@  - + - - + + - OrVnTQLTKIxVLZNkTlIIvRGSS1WhevCMECD0a58kSYI= + WOFMexmFiT1cRB5ZPY6zmeQ7x/Cbx//7QyPjwnjKGnA= diff --git a/public/clickonce/minirouter/publish.htm b/public/clickonce/minirouter/publish.htm index 15e7497c..56a6d54b 100644 --- a/public/clickonce/minirouter/publish.htm +++ b/public/clickonce/minirouter/publish.htm @@ -59,7 +59,7 @@ FONT.key {font-weight: bold; color: darkgreen}
-
 
Name:MeshCentral Mini-Router
 
Version:2.0.0.19
 
Publisher:Meshcentral.com
 
+
 
Name:MeshCentral Mini-Router
 
Version:2.0.0.22
 
Publisher:Meshcentral.com
 
diff --git a/webserver.js b/webserver.js index d2f1bea8..21f315b2 100644 --- a/webserver.js +++ b/webserver.js @@ -161,7 +161,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { for (i in obj.certificates.dns) { if (obj.parent.config.domains[i].dns != null) { obj.dnsDomains[obj.parent.config.domains[i].dns.toLowerCase()] = obj.parent.config.domains[i]; obj.tlsSniCredentials[obj.parent.config.domains[i].dns] = obj.tls.createSecureContext(obj.certificates.dns[i]).context; dnscount++; } } if (dnscount > 0) { obj.tlsSniCredentials[''] = obj.tls.createSecureContext({ cert: obj.certificates.web.cert, key: obj.certificates.web.key, ca: obj.certificates.web.ca }).context; } else { obj.tlsSniCredentials = null; } } - function TlsSniCallback(name, cb) { var c = obj.tlsSniCredentials[name]; if (c != null) { cb(null, c); } else { cb(null, obj.tlsSniCredentials['']); } } + function TlsSniCallback(name, cb) { + var c = obj.tlsSniCredentials[name]; + if (c != null) { + cb(null, c); + } else { + cb(null, obj.tlsSniCredentials['']); + } + } function EscapeHtml(x) { if (typeof x == "string") return x.replace(/&/g, '&').replace(/>/g, '>').replace(//g, '>').replace(/').replace(/\n/g, '').replace(/\t/g, '  '); if (typeof x == "boolean") return x; if (typeof x == "number") return x; } @@ -174,6 +181,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { var tlsOptions = { cert: obj.certificates.web.cert, key: obj.certificates.web.key, ca: obj.certificates.web.ca, rejectUnauthorized: true, secureOptions: obj.constants.SSL_OP_NO_SSLv2 | obj.constants.SSL_OP_NO_SSLv3 | obj.constants.SSL_OP_NO_COMPRESSION | obj.constants.SSL_OP_CIPHER_SERVER_PREFERENCE | obj.constants.SSL_OP_NO_TLSv1 | obj.constants.SSL_OP_NO_TLSv11 }; if (obj.tlsSniCredentials != null) { tlsOptions.SNICallback = TlsSniCallback; } // We have multiple web server certificate used depending on the domain name obj.tlsServer = require('https').createServer(tlsOptions, obj.app); + obj.tlsServer.on('secureConnection', function () { }); + obj.tlsServer.on('error', function (a, b, c) { console.log('tlsServer error', a, b, c); }); obj.expressWs = require('express-ws')(obj.app, obj.tlsServer); } @@ -279,9 +288,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { function checkUserIpAddressEx(req, res, allowedIpList) { if (allowedIpList == null) { return true; } try { - var ip = req.ip, type = 0; - if (req.connection) { type = 1; } // HTTP(S) request - else if (req._socket) { type = 2; } // WebSocket request + var ip, type = 0; + if (req.connection) { type = 1; ip = req.ip; } // HTTP(S) request + else if (req._socket) { type = 2; ip = req._socket.remoteAddress; } // WebSocket request + if (!ip) return false; if (ip.startsWith('::ffff:')) { ip = ip.substring(7); } // Fix IPv4 IP's encoded in IPv6 form if ((ip != null) && (allowedIpList.indexOf(ip) >= 0)) { return true; } if (type == 1) { res.sendStatus(401); }