MeshCMD routing improvements.

Ylian Saint-Hilaire committed May 25, 2021 at 17:10 UTC 17437467a13b5feda596d85706e11ec97f94795c
3 files changed +4 -1
agents/MeshCmd-signed.exe
Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ
agents/MeshCmd64-signed.exe
Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ
agents/meshcmd.js
+4 -1
@@ -2005,7 +2005,7 @@ function startRouter() {
2005 if (xurlargs.length > 0) { options.path += '?' + xurlargs.join('&'); }
2006 } catch (e) { console.log("Unable to parse \"serverUrl\"."); process.exit(1); return; }
2007
2008 - console.log("Connecting...", options);
2008 + debug(1, "Connecting to " + options.host + ".");
2009 options.checkServerIdentity = onVerifyServer;
2010 options.rejectUnauthorized = false;
2011 settings.websocket = http.request(options);
@@ -2015,6 +2015,7 @@ function startRouter() {
2015 }
2016
2017 function OnServerWebSocket(msg, s, head) {
2018 + debug(1, "Connected...");
2019 settings.webchannel = s;
2020 s.on('data', function (msg) {
2021 var command = JSON.parse(msg);
@@ -2064,6 +2065,7 @@ function OnServerWebSocket(msg, s, head) {
2065 // Hash the signed data and verify the server signature
2066 var signDataHash = hasher.syncHash(Buffer.concat([Buffer.from(settings.serverAuthClientNonce, 'base64'), Buffer.from(settings.meshServerTlsHash, 'hex'), Buffer.from(command.nonce, 'base64')]));
2067 if (require('RSA').verify(require('RSA').TYPES.SHA384, cert, signDataHash, Buffer.from(command.signature, 'base64')) == false) { console.log("Unable to authenticate the server, invalid signature."); process.exit(1); return; }
2068 + debug(1, "Authenticated the server.");
2069
2070 // Switch to using HTTPS TLS certificate for authentication
2071 delete settings.serverid;
@@ -2099,6 +2101,7 @@ function OnServerWebSocket(msg, s, head) {
2101
2102 // Perform inner server authentication
2103 if (settings.serverid != null) {
2104 + debug(1, "Authenticating the server...");
2105 settings.serverAuthClientNonce = require('EncryptionStream').GenerateRandom(48).toString('base64');
2106 s.write("{\"action\":\"serverAuth\",\"cnonce\":\"" + settings.serverAuthClientNonce + "\",\"tlshash\":\"" + settings.meshServerTlsHash + "\"}"); // Ask for server authentication
2107 }