Updated Windows Agents.
Ylian Saint-Hilaire committed
Dec 10, 2019 at 18:17 UTC
96f568db9b4205b349fe4933d9c0f9744b390baf
14 files changed
+108
-34
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/MeshService-signed.exe
Binary files a/agents/MeshService-signed.exe and b/agents/MeshService-signed.exe differ
agents/MeshService.exe
Binary files a/agents/MeshService.exe and b/agents/MeshService.exe differ
agents/MeshService64-signed.exe
Binary files a/agents/MeshService64-signed.exe and b/agents/MeshService64-signed.exe differ
agents/MeshService64.exe
Binary files a/agents/MeshService64.exe and b/agents/MeshService64.exe differ
agents/meshcore.min.js
+82
-18
@@ -1109,28 +1109,58 @@ function createMeshCore(agent) {
1109
{
1110
try
1111
{
1112
- if (((this.httprequest.protocol == 6) || (this.httprequest.protocol == 8)) && (require('win-terminal').PowerShellCapable() == true)) {
1113
- if (require('win-virtual-terminal').supported) {
1114
- this.httprequest._term = require('win-virtual-terminal').StartPowerShell(80, 25); // TODO: Start as logged in used when protocol is 8
1115
- } else {
1116
- this.httprequest._term = require('win-terminal').StartPowerShell(80, 25); // TODO: Start as logged in used when protocol is 8
1112
+ if (!require('win-terminal').PowerShellCapable() && (this.httprequest.protocol == 6 || this.httprequest.protocol == 9)) { throw ('PowerShell is not supported on this version of windows'); }
1113
+ if ((this.httprequest.protocol == 1) || (this.httprequest.protocol == 6))
1114
+ {
1115
+ // Admin Terminal
1116
+ if (require('win-virtual-terminal').supported)
1117
+ {
1118
+ // ConPTY PseudoTerminal
1119
+ this.httprequest._term = require('win-virtual-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25);
1120
}
1118
- } else {
1119
- if (require('win-virtual-terminal').supported) {
1120
- this.httprequest._term = require('win-virtual-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 8
1121
- } else {
1122
- this.httprequest._term = require('win-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 8
1121
+ else
1122
+ {
1123
+ // Legacy Terminal
1124
+ this.httprequest._term = require('win-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25);
1125
}
1126
}
1125
- } catch (e) {
1127
+ else
1128
+ {
1129
+ // Logged in user
1130
+ var username = require('user-sessions').getUsername(require('user-sessions').consoleUid());
1131
+ if (require('win-virtual-terminal').supported)
1132
+ {
1133
+ // ConPTY PseudoTerminal
1134
+ this.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-virtual-terminal', script: getJSModule('win-virtual-terminal') }], launch: { module: 'win-virtual-terminal', method: (this.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } });
1135
+ }
1136
+ else
1137
+ {
1138
+ // Legacy Terminal
1139
+ this.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-terminal', script: getJSModule('win-terminal') }], launch: { module: 'win-terminal', method: (this.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } });
1140
+ }
1141
+ this.httprequest._dispatcher.ws = this;
1142
+ this.httprequest._dispatcher.on('connection', function (c)
1143
+ {
1144
+ console.log('client connected');
1145
+ this.ws._term = c;
1146
+ c.pipe(this.ws, { dataTypeSkip: 1 });
1147
+ this.ws.pipe(c, { dataTypeSkip: 1, end: false });
1148
+ this.ws.prependListener('end', function () { this.httprequest._term.end(function () { console.log("Terminal was closed"); }); });
1149
+ });
1150
+ }
1151
+ } catch (e)
1152
+ {
1153
MeshServerLog('Failed to start remote terminal session, ' + e.toString() + ' (' + this.httprequest.remoteaddr + ')', this.httprequest);
1154
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
1155
this.end();
1156
return;
1157
}
1131
- this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
1132
- this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
1133
- this.prependListener('end', function () { this.httprequest._term.end(function () { console.log("Terminal was closed"); }); });
1158
+ if (!this.httprequest._dispatcher)
1159
+ {
1160
+ this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
1161
+ this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
1162
+ this.prependListener('end', function () { this.httprequest._term.end(function () { console.log("Terminal was closed"); }); });
1163
+ }
1164
}
1165
else
1166
{
@@ -1212,7 +1242,7 @@ function createMeshCore(agent) {
1242
}
1243
1244
// Remote desktop using native pipes
1215
- this.httprequest.desktop = { state: 0, kvm: mesh.getRemoteDesktopStream(), tunnel: this };
1245
+ this.httprequest.desktop = { state: 0, kvm: mesh.getRemoteDesktopStream(require('MeshAgent')._tsid == null ? undefined : require('MeshAgent')._tsid), tunnel: this };
1246
this.httprequest.desktop.kvm.parent = this.httprequest.desktop;
1247
this.desktop = this.httprequest.desktop;
1248
@@ -1256,7 +1286,7 @@ function createMeshCore(agent) {
1286
this.httprequest.desktop.kvm.connectionBar.removeAllListeners('close');
1287
this.httprequest.desktop.kvm.connectionBar.close();
1288
1259
- this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.httprequest.desktop.kvm.users.sort().join(', '));
1289
+ this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.httprequest.desktop.kvm.users.sort().join(', '), require('MeshAgent')._tsid);
1290
this.httprequest.desktop.kvm.connectionBar.httprequest = this.httprequest;
1291
this.httprequest.desktop.kvm.connectionBar.on('close', function ()
1292
{
@@ -1321,7 +1351,7 @@ function createMeshCore(agent) {
1351
}
1352
try
1353
{
1324
- this.ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.ws.httprequest.desktop.kvm.users.sort().join(', '));
1354
+ this.ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.ws.httprequest.desktop.kvm.users.sort().join(', '), require('MeshAgent')._tsid);
1355
MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.ws.httprequest.remoteaddr + ')', this.ws.httprequest);
1356
}
1357
catch(xx)
@@ -1375,7 +1405,7 @@ function createMeshCore(agent) {
1405
}
1406
try
1407
{
1378
- this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.httprequest.desktop.kvm.users.sort().join(', '));
1408
+ this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.httprequest.desktop.kvm.users.sort().join(', '), require('MeshAgent')._tsid);
1409
MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.httprequest.remoteaddr + ')', this.httprequest);
1410
}
1411
catch(xx)
@@ -1836,6 +1866,40 @@ function createMeshCore(agent) {
1866
response = 'Available commands: \r\n' + fin + '.';
1867
break;
1868
}
1869
+ case 'tsid':
1870
+ if (process.platform == 'win32')
1871
+ {
1872
+ if (args['_'].length != 1)
1873
+ {
1874
+ response = 'TSID: ' + (require('MeshAgent')._tsid == null ? 'console' : require('MeshAgent')._tsid);
1875
+ }
1876
+ else
1877
+ {
1878
+ var i = parseInt(args['_'][0]);
1879
+ require('MeshAgent')._tsid = (isNaN(i) ? null : i);
1880
+ response = 'TSID set to: ' + (require('MeshAgent')._tsid == null ? 'console' : require('MeshAgent')._tsid);
1881
+ }
1882
+ }
1883
+ break;
1884
+ case 'activeusers':
1885
+ if (process.platform == 'win32')
1886
+ {
1887
+ var p = require('user-sessions').enumerateUsers();
1888
+ p.sessionid = sessionid;
1889
+ p.then(function (u)
1890
+ {
1891
+ var v = [];
1892
+ for(var i in u)
1893
+ {
1894
+ if(u[i].State == 'Active' || u[i].State == 'Connected')
1895
+ {
1896
+ v.push({ tsid: i, type: u[i].StationName, user: u[i].Username });
1897
+ }
1898
+ }
1899
+ sendConsoleText(JSON.stringify(v, null, 1), this.sessionid);
1900
+ });
1901
+ }
1902
+ break;
1903
case 'wallpaper':
1904
if (process.platform != 'win32' && !(process.platform == 'linux' && require('linux-gnome-helpers').available))
1905
{
agents/modules_meshcore/win-virtual-terminal.js
+4
-4
@@ -115,18 +115,18 @@ function vt()
115
ds.terminal = ret;
116
ds._rpbuf = GM.CreateVariable(4096);
117
ds._rpbufRead = GM.CreateVariable(4);
118
- ds._read = function _read()
118
+ ds.__read = function __read()
119
{
120
- this._rp = this.terminal.k32.ReadFile.async(this.terminal._output.Deref(), this._rpbuf, this._rpbuf._size, this._rpbufRead, 0);
120
+ this._rp = this.terminal.k32.ReadFile.async(this.terminal._output.Deref(), this._rpbuf, this._rpbuf._size, this._rpbufRead, 0);
121
this._rp.then(function ()
122
{
123
var len = this.parent._rpbufRead.toBuffer().readUInt32LE();
124
this.parent.push(this.parent._rpbuf.toBuffer().slice(0, len));
125
- this.parent._read();
125
+ this.parent.__read();
126
});
127
this._rp.parent = this;
128
};
129
- ds._read();
129
+ ds.__read();
130
return (ds);
131
}
132
else
agents/modules_meshcore_min/win-virtual-terminal.min.js
+1
-1
@@ -1 +1 @@
1
-var PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE=131094;var EXTENDED_STARTUPINFO_PRESENT=524288;var HEAP_ZERO_MEMORY=8;var duplex=require("stream").Duplex;function vt(){this._ObjectID="win-virtual-terminal";Object.defineProperty(this,"supported",{value:(function(){var f=require("_GenericMarshal");var g=f.CreateNativeProxy("kernel32.dll");try{g.CreateMethod("CreatePseudoConsole")}catch(d){return(false)}return(true)})()});this.Create=function a(k,o,i){if(!this.supported){throw ("This build of Windows does not have support for PseudoConsoles")}if(!o){o=80}if(!i){i=25}var h=require("_GenericMarshal");var j=h.CreateNativeProxy("kernel32.dll");j.CreateMethod("CreatePipe");j.CreateMethod("CreateProcessW");j.CreateMethod("CreatePseudoConsole");j.CreateMethod("GetProcessHeap");j.CreateMethod("HeapAlloc");j.CreateMethod("InitializeProcThreadAttributeList");j.CreateMethod("UpdateProcThreadAttribute");j.CreateMethod("WriteFile");j.CreateMethod("ReadFile");j.CreateMethod("TerminateProcess");var m={_h:h.CreatePointer(),_consoleInput:h.CreatePointer(),_consoleOutput:h.CreatePointer(),_input:h.CreatePointer(),_output:h.CreatePointer(),k32:j};var f=h.CreateVariable(8);var e;var l=h.CreateVariable(h.PointerSize==4?16:24);if(j.CreatePipe(m._consoleInput,m._input,0,0).Val==0){console.log("PIPE/FAIL")}if(j.CreatePipe(m._output,m._consoleOutput,0,0).Val==0){console.log("PIPE/FAIL")}if(j.CreatePseudoConsole((i<<16)|o,m._consoleInput.Deref(),m._consoleOutput.Deref(),0,m._h).Val!=0){throw ("Error calling CreatePseudoConsole()")}j.InitializeProcThreadAttributeList(0,1,0,f);e=h.CreateVariable(f.toBuffer().readUInt32LE());var n=h.CreateVariable(h.PointerSize==8?112:72);n.toBuffer().writeUInt32LE(h.PointerSize==8?112:72,0);e.pointerBuffer().copy(n.Deref(h.PointerSize==8?104:68,h.PointerSize).toBuffer());if(j.InitializeProcThreadAttributeList(e,1,0,f).Val!=0){if(j.UpdateProcThreadAttribute(e,0,PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE,m._h.Deref(),h.PointerSize,0,0).Val!=0){if(j.CreateProcessW(0,h.CreateVariable(k,{wide:true}),0,0,1,EXTENDED_STARTUPINFO_PRESENT,0,0,n,l).Val!=0){m._startupinfoex=n;m._process=l.Deref(0);m._pid=l.Deref(h.PointerSize==4?8:16,4).toBuffer().readUInt32LE();var g=new duplex({write:function(p,q){var r=require("_GenericMarshal").CreateVariable(4);this.terminal.k32.WriteFile(this.terminal._input.Deref(),require("_GenericMarshal").CreateVariable(p),p.length,r,0);q();return(true)},"final":function(p){if(this.terminal._process){this.terminal.k32.TerminateProcess(this.terminal._process,0);this.terminal._process=null;this.terminal.k32.ReadFile.async.abort()}p()}});m._waiter=require("DescriptorEvents").addDescriptor(l.Deref(0));m._waiter.ds=g;m._waiter.on("signaled",function(){this.ds.push(null)});g.terminal=m;g._rpbuf=h.CreateVariable(4096);g._rpbufRead=h.CreateVariable(4);g._read=function d(){this._rp=this.terminal.k32.ReadFile.async(this.terminal._output.Deref(),this._rpbuf,this._rpbuf._size,this._rpbufRead,0);this._rp.then(function(){var p=this.parent._rpbufRead.toBuffer().readUInt32LE();this.parent.push(this.parent._rpbuf.toBuffer().slice(0,p));this.parent._read()});this._rp.parent=this};g._read();return(g)}else{console.log("FAILED!")}}}throw ("Internal Error")};this.PowerShellCapable=function(){if(require("os").arch()=="x64"){return(require("fs").existsSync(process.env.windir+"\\SysWow64\\WindowsPowerShell\\v1.0\\powershell.exe"))}else{return(require("fs").existsSync(process.env.windir+"\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"))}};this.Start=function b(e,d){return(this.Create(process.env.windir+"\\System32\\cmd.exe",e,d))};this.StartPowerShell=function c(e,d){if(require("os").arch()=="x64"){return(this.Create(process.env.windir+"\\SysWow64\\WindowsPowerShell\\v1.0\\powershell.exe",e,d))}else{return(this.Create(process.env.windir+"\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",e,d))}}}if(process.platform=="win32"){module.exports=new vt()};
\ No newline at end of file
1
+var PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE=131094;var EXTENDED_STARTUPINFO_PRESENT=524288;var HEAP_ZERO_MEMORY=8;var duplex=require("stream").Duplex;function vt(){this._ObjectID="win-virtual-terminal";Object.defineProperty(this,"supported",{value:(function(){var f=require("_GenericMarshal");var g=f.CreateNativeProxy("kernel32.dll");try{g.CreateMethod("CreatePseudoConsole")}catch(d){return(false)}return(true)})()});this.Create=function a(k,o,i){if(!this.supported){throw ("This build of Windows does not have support for PseudoConsoles")}if(!o){o=80}if(!i){i=25}var h=require("_GenericMarshal");var j=h.CreateNativeProxy("kernel32.dll");j.CreateMethod("CreatePipe");j.CreateMethod("CreateProcessW");j.CreateMethod("CreatePseudoConsole");j.CreateMethod("GetProcessHeap");j.CreateMethod("HeapAlloc");j.CreateMethod("InitializeProcThreadAttributeList");j.CreateMethod("UpdateProcThreadAttribute");j.CreateMethod("WriteFile");j.CreateMethod("ReadFile");j.CreateMethod("TerminateProcess");var m={_h:h.CreatePointer(),_consoleInput:h.CreatePointer(),_consoleOutput:h.CreatePointer(),_input:h.CreatePointer(),_output:h.CreatePointer(),k32:j};var f=h.CreateVariable(8);var e;var l=h.CreateVariable(h.PointerSize==4?16:24);if(j.CreatePipe(m._consoleInput,m._input,0,0).Val==0){console.log("PIPE/FAIL")}if(j.CreatePipe(m._output,m._consoleOutput,0,0).Val==0){console.log("PIPE/FAIL")}if(j.CreatePseudoConsole((i<<16)|o,m._consoleInput.Deref(),m._consoleOutput.Deref(),0,m._h).Val!=0){throw ("Error calling CreatePseudoConsole()")}j.InitializeProcThreadAttributeList(0,1,0,f);e=h.CreateVariable(f.toBuffer().readUInt32LE());var n=h.CreateVariable(h.PointerSize==8?112:72);n.toBuffer().writeUInt32LE(h.PointerSize==8?112:72,0);e.pointerBuffer().copy(n.Deref(h.PointerSize==8?104:68,h.PointerSize).toBuffer());if(j.InitializeProcThreadAttributeList(e,1,0,f).Val!=0){if(j.UpdateProcThreadAttribute(e,0,PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE,m._h.Deref(),h.PointerSize,0,0).Val!=0){if(j.CreateProcessW(0,h.CreateVariable(k,{wide:true}),0,0,1,EXTENDED_STARTUPINFO_PRESENT,0,0,n,l).Val!=0){m._startupinfoex=n;m._process=l.Deref(0);m._pid=l.Deref(h.PointerSize==4?8:16,4).toBuffer().readUInt32LE();var g=new duplex({write:function(p,q){var r=require("_GenericMarshal").CreateVariable(4);this.terminal.k32.WriteFile(this.terminal._input.Deref(),require("_GenericMarshal").CreateVariable(p),p.length,r,0);q();return(true)},"final":function(p){if(this.terminal._process){this.terminal.k32.TerminateProcess(this.terminal._process,0);this.terminal._process=null;this.terminal.k32.ReadFile.async.abort()}p()}});m._waiter=require("DescriptorEvents").addDescriptor(l.Deref(0));m._waiter.ds=g;m._waiter.on("signaled",function(){this.ds.push(null)});g.terminal=m;g._rpbuf=h.CreateVariable(4096);g._rpbufRead=h.CreateVariable(4);g.__read=function d(){this._rp=this.terminal.k32.ReadFile.async(this.terminal._output.Deref(),this._rpbuf,this._rpbuf._size,this._rpbufRead,0);this._rp.then(function(){var p=this.parent._rpbufRead.toBuffer().readUInt32LE();this.parent.push(this.parent._rpbuf.toBuffer().slice(0,p));this.parent.__read()});this._rp.parent=this};g.__read();return(g)}else{console.log("FAILED!")}}}throw ("Internal Error")};this.PowerShellCapable=function(){if(require("os").arch()=="x64"){return(require("fs").existsSync(process.env.windir+"\\SysWow64\\WindowsPowerShell\\v1.0\\powershell.exe"))}else{return(require("fs").existsSync(process.env.windir+"\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"))}};this.Start=function b(e,d){return(this.Create(process.env.windir+"\\System32\\cmd.exe",e,d))};this.StartPowerShell=function c(e,d){if(require("os").arch()=="x64"){return(this.Create(process.env.windir+"\\SysWow64\\WindowsPowerShell\\v1.0\\powershell.exe",e,d))}else{return(this.Create(process.env.windir+"\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",e,d))}}}if(process.platform=="win32"){module.exports=new vt()};
\ No newline at end of file
meshcentral.js
+2
-1
@@ -1979,7 +1979,8 @@ function CreateMeshCentralServer(config, args) {
1979
function logInfoEvent(msg) { if (obj.servicelog != null) { obj.servicelog.info(msg); } console.log(msg); }
1980
function logWarnEvent(msg) { if (obj.servicelog != null) { obj.servicelog.warn(msg); } console.log(msg); }
1981
function logErrorEvent(msg) { if (obj.servicelog != null) { obj.servicelog.error(msg); } console.error(msg); }
1982
- obj.getServerWarnings = function() { return serverWarnings; }
1982
+ obj.getServerWarnings = function () { return serverWarnings; }
1983
+ obj.addServerWarning = function(msg, print) { serverWarnings.push(msg); if (print !== false) { console.log("WARNING: " + msg); } }
1984
1985
// Return the path of a file into the meshcentral-data path
1986
obj.getConfigFilePath = function (filename) {
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.4.5-o",
3
+ "version": "0.4.5-p",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
translate/translate.js
+2
-2
@@ -285,7 +285,7 @@ function fromtext(source, target, lang) {
285
var splitOutput = [];
286
for (var i in sourceLangFileData.strings) {
287
if ((sourceLangFileData.strings[i]['en'] != null) && (sourceLangFileData.strings[i]['en'].indexOf('\r') == -1) && (sourceLangFileData.strings[i]['en'].indexOf('\n') == -1)) {
288
- sourceLangFileData.strings[i][lang] = rawTextArray[i];
288
+ if (sourceLangFileData.strings[i][lang] == null) { sourceLangFileData.strings[i][lang] = rawTextArray[i]; }
289
}
290
}
291
@@ -313,7 +313,7 @@ function merge(source, target, lang) {
313
// Merge the translation
314
for (var i in sourceLangFileData.strings) {
315
if ((sourceLangFileData.strings[i].en != null) && (sourceLangFileData.strings[i][lang] != null) && (index[sourceLangFileData.strings[i].en] != null)) {
316
- index[sourceLangFileData.strings[i].en][lang] = sourceLangFileData.strings[i][lang];
316
+ if (sourceLangFileData.strings[i][lang] == null) { index[sourceLangFileData.strings[i].en][lang] = sourceLangFileData.strings[i][lang]; }
317
}
318
}
319
views/default.handlebars
+2
-6
@@ -58,8 +58,8 @@
58
<div id="termShellContextMenu" class="contextMenu noselect" style="display:none;min-width:0px">
59
<div id="cxtermnorm" class="cmtext" onclick="cmtermaction(1,event)"><b>Admin Shell</b></div>
60
<div id="cxtermps" class="cmtext" onclick="cmtermaction(6,event)">Admin PowerShell</div>
61
- <div id="cxtermunorm" class="cmtext" style="display:none" onclick="cmtermaction(8,event)">User Shell</div>
62
- <div id="cxtermups" class="cmtext" style="display:none" onclick="cmtermaction(9,event)">User PowerShell</div>
61
+ <div id="cxtermunorm" class="cmtext" onclick="cmtermaction(8,event)">User Shell</div>
62
+ <div id="cxtermups" class="cmtext" onclick="cmtermaction(9,event)">User PowerShell</div>
63
</div>
64
<div id="termShellContextMenuLinux" class="contextMenu noselect" style="display:none;min-width:0px">
65
<div id="cxtermnorm" class="cmtext" onclick="cmtermaction(1,event)"><b>Root Shell</b></div>
@@ -1106,10 +1106,6 @@
1106
if (nightMode) { QC('body').add('night'); }
1107
toggleFullScreen();
1108
1109
- // Debug
1110
- QV('cxtermunorm', debugmode == 1);
1111
- QV('cxtermups', debugmode == 1);
1112
-
1109
// Setup page visuals
1110
if (args.hide) {
1111
var hide = parseInt(args.hide);
webserver.js
+14
-1
@@ -3716,7 +3716,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3716
3717
// Start the ExpressJS web server
3718
function StartWebServer(port) {
3719
- if (port == 0 || port == 65535) return;
3719
+ if ((port < 1) || (port > 65535)) return;
3720
obj.args.port = port;
3721
if (obj.tlsServer != null) {
3722
if (obj.args.lanonly == true) {
@@ -3732,6 +3732,19 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3732
obj.parent.updateServerState('http-port', port);
3733
if (args.aliasport != null) { obj.parent.updateServerState('http-aliasport', args.aliasport); }
3734
}
3735
+
3736
+ // Check if there is a permissions problem with the ports.
3737
+ if (require('os').platform() != 'win32') {
3738
+ var expectedPort = obj.parent.config.settings.port ? obj.parent.config.settings.port : 443;
3739
+ if ((expectedPort != port) && (port >= 1024) && (port < 1034)) {
3740
+ console.log('');
3741
+ console.log('WARNING: MeshCentral is running without permissions to use ports below 1025.');
3742
+ console.log(' Use setcap to grant access to lower ports, or read installation guide.');
3743
+ console.log('');
3744
+ console.log(' sudo setcap \'cap_net_bind_service= +ep\' `which node` \r\n');
3745
+ obj.parent.addServerWarning('Server running without permissions to use ports below 1025.', false);
3746
+ }
3747
+ }
3748
}
3749
3750
// Force mesh agent disconnection