add relay and port to devicesharing in meshctrl.js
Signed-off-by: si458 <simonsmith5521@gmail.com>
Simon Smith committed
Mar 2, 2024 at 21:56 UTC
2318a0bb327bdfaa797c348b5942a120aa21756a
1 file changed
+31
-14
meshctrl.js
+31
-14
@@ -879,6 +879,7 @@ if (args['_'].length == 0) {
879
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid' --add Guest --start " + localISOTime + " --duration 30"));
880
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid' --add Guest --start " + localISOTime + " --duration 30 --daily"));
881
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid' --add Guest --type desktop,terminal --consent prompt"));
882
+ console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid' --add Guest --type http --port 80"));
883
console.log("\r\nRequired arguments:\r\n");
884
if (process.platform == 'win32') {
885
console.log(" --id [deviceid] - The device identifier.");
@@ -886,16 +887,17 @@ if (args['_'].length == 0) {
887
console.log(" --id '[deviceid]' - The device identifier.");
888
}
889
console.log("\r\nOptional arguments:\r\n");
889
- console.log(" --remove [shareid] - Remove a device sharing link.");
890
- console.log(" --add [guestname] - Add a device sharing link.");
891
- console.log(" --type [desktop,terminal,files] - Type of sharing to add, can be combined. default is desktop.");
892
- console.log(" --viewonly - Make desktop sharing view only.");
893
- console.log(" --consent [notify,prompt,none] - Consent flags, default is notify.");
894
- console.log(" --start [yyyy-mm-ddThh:mm:ss] - Start time, default is now.");
895
- console.log(" --end [yyyy-mm-ddThh:mm:ss] - End time.");
896
- console.log(" --duration [minutes] - Duration of the share, default is 60 minutes.");
897
- console.log(" --daily - Add recurring daily device share.");
898
- console.log(" --weekly - Add recurring weekly device share.");
890
+ console.log(" --remove [shareid] - Remove a device sharing link.");
891
+ console.log(" --add [guestname] - Add a device sharing link.");
892
+ console.log(" --type [desktop,terminal,files,http,https] - Type of sharing to add, can be combined. default is desktop.");
893
+ console.log(" --viewonly - Make desktop sharing view only.");
894
+ console.log(" --consent [notify,prompt,none] - Consent flags, default is notify.");
895
+ console.log(" --start [yyyy-mm-ddThh:mm:ss] - Start time, default is now.");
896
+ console.log(" --end [yyyy-mm-ddThh:mm:ss] - End time.");
897
+ console.log(" --duration [minutes] - Duration of the share, default is 60 minutes.");
898
+ console.log(" --daily - Add recurring daily device share.");
899
+ console.log(" --weekly - Add recurring weekly device share.");
900
+ console.log(" --port [portnumber] - Set alternative port for http or https, default is 80 for http and 443 for https.");
901
break;
902
}
903
case 'agentdownload': {
@@ -1707,10 +1709,12 @@ function serverConnect() {
1709
var p = 0;
1710
if (args.type != null) {
1711
var shareTypes = args.type.toLowerCase().split(',');
1710
- for (var i in shareTypes) { if ((shareTypes[i] != 'terminal') && (shareTypes[i] != 'desktop') && (shareTypes[i] != 'files')) { console.log("Unknown sharing type: " + shareTypes[i]); process.exit(1); } }
1712
+ for (var i in shareTypes) { if ((shareTypes[i] != 'terminal') && (shareTypes[i] != 'desktop') && (shareTypes[i] != 'files') && (shareTypes[i] != 'http') && (shareTypes[i] != 'https')) { console.log("Unknown sharing type: " + shareTypes[i]); process.exit(1); } }
1713
if (shareTypes.indexOf('terminal') >= 0) { p |= 1; }
1714
if (shareTypes.indexOf('desktop') >= 0) { p |= 2; }
1715
if (shareTypes.indexOf('files') >= 0) { p |= 4; }
1716
+ if (shareTypes.indexOf('http') >= 0) { p |= 8; }
1717
+ if (shareTypes.indexOf('https') >= 0) { p |= 16; }
1718
}
1719
if (p == 0) { p = 2; } // Desktop
1720
@@ -1745,6 +1749,19 @@ function serverConnect() {
1749
}
1750
}
1751
1752
+ var port = null;
1753
+ // Set Port Number if http or https
1754
+ if ((p & 8) || (p & 16)) {
1755
+ if (typeof args.port == 'number') {
1756
+ if ((args.port < 1) || (args.port > 65535)) { console.log("Port number must be between 1 and 65535."); process.exit(1); }
1757
+ port = args.port;
1758
+ } else if ((p & 8)) {
1759
+ port = 80;
1760
+ } else if ((p & 16)) {
1761
+ port = 443;
1762
+ }
1763
+ }
1764
+
1765
// Start and end time
1766
var start = null, end = null;
1767
if (args.start) { start = Math.floor(Date.parse(args.start) / 1000); end = start + (60 * 60); }
@@ -1761,14 +1778,14 @@ function serverConnect() {
1778
if ((typeof args.duration != 'number') || (args.duration < 1)) { console.log("Invalid duration value."); process.exit(1); return; }
1779
1780
// Recurring sharing
1764
- ws.send(JSON.stringify({ action: 'createDeviceShareLink', nodeid: args.id, guestname: args.add, p: p, consent: consent, start: start, expire: args.duration, recurring: recurring, viewOnly: viewOnly, responseid: 'meshctrl' }));
1781
+ ws.send(JSON.stringify({ action: 'createDeviceShareLink', nodeid: args.id, guestname: args.add, p: p, consent: consent, start: start, expire: args.duration, recurring: recurring, viewOnly: viewOnly, port: port, responseid: 'meshctrl' }));
1782
} else {
1783
if ((start == null) && (end == null)) {
1784
// Unlimited sharing
1768
- ws.send(JSON.stringify({ action: 'createDeviceShareLink', nodeid: args.id, guestname: args.add, p: p, consent: consent, expire: 0, viewOnly: viewOnly, responseid: 'meshctrl' }));
1785
+ ws.send(JSON.stringify({ action: 'createDeviceShareLink', nodeid: args.id, guestname: args.add, p: p, consent: consent, expire: 0, viewOnly: viewOnly, port: port, responseid: 'meshctrl' }));
1786
} else {
1787
// Time limited sharing
1771
- ws.send(JSON.stringify({ action: 'createDeviceShareLink', nodeid: args.id, guestname: args.add, p: p, consent: consent, start: start, end: end, viewOnly: viewOnly, responseid: 'meshctrl' }));
1788
+ ws.send(JSON.stringify({ action: 'createDeviceShareLink', nodeid: args.id, guestname: args.add, p: p, consent: consent, start: start, end: end, viewOnly: viewOnly, port: port, responseid: 'meshctrl' }));
1789
}
1790
}
1791
} else if (args.remove) {