Added loginkey support to meshctrl.js

Ylian Saint-Hilaire committed Sep 18, 2020 at 11:09 UTC 048eb8be39fd9e66549857fdf469174638afd8fa
1 file changed +4
meshctrl.js
+4
@@ -51,6 +51,7 @@ if (args['_'].length == 0) {
51 console.log(" DeviceToast - Display a toast notification on a remote device.");
52 console.log("\r\nSupported login arguments:");
53 console.log(" --url [wss://server] - Server url, wss://localhost:443 is default.");
54 + console.log(" - Use wss://localhost:443?key=xxx if login key is required.");
55 console.log(" --loginuser [username] - Login username, admin is default.");
56 console.log(" --loginpass [password] - Login password.");
57 console.log(" --token [number] - 2nd factor authentication token.");
@@ -789,8 +790,11 @@ function serverConnect() {
790 url = args.url;
791 if (url.length < 5) { console.log("Invalid url."); process.exit(); return; }
792 if ((url.startsWith('wss://') == false) && (url.startsWith('ws://') == false)) { console.log("Invalid url."); process.exit(); return; }
793 + var i = url.indexOf('?key='), loginKey = null;
794 + if (i >= 0) { loginKey = url.substring(i + 5); url = url.substring(0, i); }
795 if (url.endsWith('/') == false) { url += '/'; }
796 url += 'control.ashx';
797 + if (loginKey != null) { url += '?key=' + loginKey; }
798 }
799
800 // TODO: checkServerIdentity does not work???