Added loginkey support to meshctrl.js

This commit is contained in:
Ylian Saint-Hilaire 2020-09-18 11:09:03 -07:00
parent 2313e64e3a
commit 048eb8be39

View File

@ -51,6 +51,7 @@ if (args['_'].length == 0) {
console.log(" DeviceToast - Display a toast notification on a remote device."); console.log(" DeviceToast - Display a toast notification on a remote device.");
console.log("\r\nSupported login arguments:"); console.log("\r\nSupported login arguments:");
console.log(" --url [wss://server] - Server url, wss://localhost:443 is default."); 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(" --loginuser [username] - Login username, admin is default.");
console.log(" --loginpass [password] - Login password."); console.log(" --loginpass [password] - Login password.");
console.log(" --token [number] - 2nd factor authentication token."); console.log(" --token [number] - 2nd factor authentication token.");
@ -789,8 +790,11 @@ function serverConnect() {
url = args.url; url = args.url;
if (url.length < 5) { console.log("Invalid url."); process.exit(); return; } 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; } 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 += '/'; } if (url.endsWith('/') == false) { url += '/'; }
url += 'control.ashx'; url += 'control.ashx';
if (loginKey != null) { url += '?key=' + loginKey; }
} }
// TODO: checkServerIdentity does not work??? // TODO: checkServerIdentity does not work???