Meshcore revert.
Ylian Saint-Hilaire committed
Oct 28, 2019 at 09:21 UTC
a99c985ee4993f141884bbbdbdd757a178cf1e44
3 files changed
+77
-25
agents/meshcore.js
-2
@@ -2572,8 +2572,6 @@ function createMeshCore(agent) {
2572
//if (process.platform == 'win32') { try { pr = require('win-info').pendingReboot(); } catch (ex) { pr = null; } } // Pending reboot
2573
if ((meshCoreObj.av == null) || (JSON.stringify(meshCoreObj.av) != JSON.stringify(av))) { meshCoreObj.av = av; mesh.SendCommand(meshCoreObj); }
2574
}
2575
-
2576
- mesh.SendCommand({ action: "plugin", plugin: "__all", hook: "sendPeriodicServerUpdate"});
2575
}
2576
2577
agents/meshcore.min.js
+76
-22
@@ -1202,7 +1202,7 @@ function createMeshCore(agent) {
1202
{
1203
for(var i in this.httprequest.desktop.kvm.users)
1204
{
1205
- if(this.httprequest.desktop.kvm.users[i] == this.httprequest.username)
1205
+ if (this.httprequest.desktop.kvm.users[i] == this.httprequest.username && this.httprequest.desktop.kvm.connectionBar)
1206
{
1207
this.httprequest.desktop.kvm.users.splice(i, 1);
1208
this.httprequest.desktop.kvm.connectionBar.removeAllListeners('close');
@@ -1266,23 +1266,36 @@ function createMeshCore(agent) {
1266
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 0x40))
1267
{
1268
// Connection Bar is required
1269
- MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.ws.httprequest.remoteaddr + ')', this.ws.httprequest);
1269
if (this.ws.httprequest.desktop.kvm.connectionBar)
1270
{
1271
this.ws.httprequest.desktop.kvm.connectionBar.removeAllListeners('close');
1272
this.ws.httprequest.desktop.kvm.connectionBar.close();
1273
}
1275
- this.ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.ws.httprequest.desktop.kvm.users.sort().join(', '));
1276
- this.ws.httprequest.desktop.kvm.connectionBar.httprequest = this.ws.httprequest;
1277
- this.ws.httprequest.desktop.kvm.connectionBar.on('close', function ()
1274
+ try
1275
{
1279
- MeshServerLog('Remote Desktop Connection forcefully closed by local user (' + this.httprequest.remoteaddr + ')', this.httprequest);
1280
- for (var i in this.httprequest.desktop.kvm._pipedStreams)
1276
+ this.ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.ws.httprequest.desktop.kvm.users.sort().join(', '));
1277
+ MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.ws.httprequest.remoteaddr + ')', this.ws.httprequest);
1278
+ }
1279
+ catch(xx)
1280
+ {
1281
+ if(process.platform != 'darwin')
1282
{
1282
- this.httprequest.desktop.kvm._pipedStreams[i].end();
1283
+ MeshServerLog('Remote Desktop Connection Bar Failed or Not Supported (' + this.ws.httprequest.remoteaddr + ')', this.ws.httprequest);
1284
}
1284
- this.httprequest.desktop.kvm.end();
1285
- });
1285
+ }
1286
+ if (this.ws.httprequest.desktop.kvm.connectionBar)
1287
+ {
1288
+ this.ws.httprequest.desktop.kvm.connectionBar.httprequest = this.ws.httprequest;
1289
+ this.ws.httprequest.desktop.kvm.connectionBar.on('close', function ()
1290
+ {
1291
+ MeshServerLog('Remote Desktop Connection forcefully closed by local user (' + this.httprequest.remoteaddr + ')', this.httprequest);
1292
+ for (var i in this.httprequest.desktop.kvm._pipedStreams)
1293
+ {
1294
+ this.httprequest.desktop.kvm._pipedStreams[i].end();
1295
+ }
1296
+ this.httprequest.desktop.kvm.end();
1297
+ });
1298
+ }
1299
}
1300
this.ws.httprequest.desktop.kvm.pipe(this.ws, { dataTypeSkip: 1 });
1301
this.ws.resume();
@@ -1307,23 +1320,33 @@ function createMeshCore(agent) {
1320
if (this.httprequest.consent && (this.httprequest.consent & 0x40))
1321
{
1322
// Connection Bar is required
1310
- MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.httprequest.remoteaddr + ')', this.httprequest);
1323
if(this.httprequest.desktop.kvm.connectionBar)
1324
{
1325
this.httprequest.desktop.kvm.connectionBar.removeAllListeners('close');
1326
this.httprequest.desktop.kvm.connectionBar.close();
1327
}
1316
- this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.httprequest.desktop.kvm.users.sort().join(', '));
1317
- this.httprequest.desktop.kvm.connectionBar.httprequest = this.httprequest;
1318
- this.httprequest.desktop.kvm.connectionBar.on('close', function ()
1328
+ try
1329
+ {
1330
+ this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.httprequest.desktop.kvm.users.sort().join(', '));
1331
+ MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.httprequest.remoteaddr + ')', this.httprequest);
1332
+ }
1333
+ catch(xx)
1334
+ {
1335
+ MeshServerLog('Remote Desktop Connection Bar Failed or not Supported (' + this.httprequest.remoteaddr + ')', this.httprequest);
1336
+ }
1337
+ if (this.httprequest.desktop.kvm.connectionBar)
1338
{
1320
- MeshServerLog('Remote Desktop Connection forcefully closed by local user (' + this.httprequest.remoteaddr + ')', this.httprequest);
1321
- for (var i in this.httprequest.desktop.kvm._pipedStreams)
1339
+ this.httprequest.desktop.kvm.connectionBar.httprequest = this.httprequest;
1340
+ this.httprequest.desktop.kvm.connectionBar.on('close', function ()
1341
{
1323
- this.httprequest.desktop.kvm._pipedStreams[i].end();
1324
- }
1325
- this.httprequest.desktop.kvm.end();
1326
- });
1342
+ MeshServerLog('Remote Desktop Connection forcefully closed by local user (' + this.httprequest.remoteaddr + ')', this.httprequest);
1343
+ for (var i in this.httprequest.desktop.kvm._pipedStreams)
1344
+ {
1345
+ this.httprequest.desktop.kvm._pipedStreams[i].end();
1346
+ }
1347
+ this.httprequest.desktop.kvm.end();
1348
+ });
1349
+ }
1350
}
1351
this.httprequest.desktop.kvm.pipe(this, { dataTypeSkip: 1 });
1352
}
@@ -1765,6 +1788,39 @@ function createMeshCore(agent) {
1788
response = 'Available commands: \r\n' + fin + '.';
1789
break;
1790
}
1791
+ case 'safemode':
1792
+ if (process.platform != 'win32')
1793
+ {
1794
+ response = 'safemode only supported on Windows Platforms'
1795
+ }
1796
+ else
1797
+ {
1798
+ if (args['_'].length != 1)
1799
+ {
1800
+ response = 'Proper usage: safemode (ON|OFF|STATUS)'; // Display usage
1801
+ }
1802
+ else
1803
+ {
1804
+ switch(args['_'][0].toUpperCase())
1805
+ {
1806
+ default:
1807
+ response = 'Proper usage: safemode (ON|OFF|STATUS)'; // Display usage
1808
+ break;
1809
+ case 'ON':
1810
+ require('win-bcd').setKey('safeboot', 'Network');
1811
+ require('win-bcd').enableSafeModeService('Mesh Agent');
1812
+ break;
1813
+ case 'OFF':
1814
+ require('win-bcd').deleteKey('safeboot');
1815
+ break;
1816
+ case 'STATUS':
1817
+ var nextboot = require('win-bcd').getKey('safeboot');
1818
+ response = 'Current: ' + require('win-bcd').bootMode + ' , NextBoot: ' + (nextboot ? nextboot : 'NORMAL');
1819
+ break;
1820
+ }
1821
+ }
1822
+ }
1823
+ break;
1824
/*
1825
case 'border':
1826
{
@@ -2516,8 +2572,6 @@ function createMeshCore(agent) {
2572
//if (process.platform == 'win32') { try { pr = require('win-info').pendingReboot(); } catch (ex) { pr = null; } } // Pending reboot
2573
if ((meshCoreObj.av == null) || (JSON.stringify(meshCoreObj.av) != JSON.stringify(av))) { meshCoreObj.av = av; mesh.SendCommand(meshCoreObj); }
2574
}
2519
-
2520
- mesh.SendCommand({ action: "plugin", plugin: "__all", hook: "sendPeriodicServerUpdate"});
2575
}
2576
2577
meshagent.js
+1
-1
@@ -1275,7 +1275,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1275
break;
1276
}
1277
case 'plugin': {
1278
- if (typeof command.plugin != 'string') break;
1278
+ if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break;
1279
try {
1280
var pluginHandler = require('./pluginHandler.js').pluginHandler(parent.parent);
1281
if (command.plugin == '__all') {