From 4e3b1dd9ba2350be68d89d0193b463e8ee7951cc Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Fri, 18 Sep 2020 11:09:03 -0700 Subject: [PATCH] Added loginkey support to meshctrl.js --- meshctrl.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meshctrl.js b/meshctrl.js index 2e56683c..e525f121 100644 --- a/meshctrl.js +++ b/meshctrl.js @@ -51,6 +51,7 @@ if (args['_'].length == 0) { console.log(" DeviceToast - Display a toast notification on a remote device."); console.log("\r\nSupported login arguments:"); console.log(" --url [wss://server] - Server url, wss://localhost:443 is default."); + console.log(" - Use wss://localhost:443?key=xxx if login key is required."); console.log(" --loginuser [username] - Login username, admin is default."); console.log(" --loginpass [password] - Login password."); console.log(" --token [number] - 2nd factor authentication token."); @@ -789,8 +790,11 @@ function serverConnect() { url = args.url; if (url.length < 5) { console.log("Invalid url."); process.exit(); return; } if ((url.startsWith('wss://') == false) && (url.startsWith('ws://') == false)) { console.log("Invalid url."); process.exit(); return; } + var i = url.indexOf('?key='), loginKey = null; + if (i >= 0) { loginKey = url.substring(i + 5); url = url.substring(0, i); } if (url.endsWith('/') == false) { url += '/'; } url += 'control.ashx'; + if (loginKey != null) { url += '?key=' + loginKey; } } // TODO: checkServerIdentity does not work???