Added desktop lock on disconnect feature, #3082.

This commit is contained in:
Ylian Saint-Hilaire 2021-09-01 12:07:09 -07:00
parent b66e124983
commit ce1d2053d0
5 changed files with 47 additions and 5 deletions

View File

@ -207,7 +207,6 @@
<Content Include="agents\compressModules.bat" /> <Content Include="agents\compressModules.bat" />
<Content Include="agents\MeshAgentOSXPackager.zip" /> <Content Include="agents\MeshAgentOSXPackager.zip" />
<Content Include="agents\meshagent_arm" /> <Content Include="agents\meshagent_arm" />
<Content Include="agents\meshagent_arm64" />
<Content Include="agents\meshagent_armhf" /> <Content Include="agents\meshagent_armhf" />
<Content Include="agents\meshagent_mips" /> <Content Include="agents\meshagent_mips" />
<Content Include="agents\meshagent_osx-x86-64" /> <Content Include="agents\meshagent_osx-x86-64" />

View File

@ -1702,6 +1702,22 @@ function onTunnelClosed() {
var tunnel = tunnels[this.httprequest.index]; var tunnel = tunnels[this.httprequest.index];
if (tunnel == null) return; // Stop duplicate calls. if (tunnel == null) return; // Stop duplicate calls.
// Perform display locking on disconnect
if ((this.httprequest.protocol == 2) && (this.httprequest.autolock === true)) {
// Look for a TSID
var tsid = null;
if ((this.httprequest.xoptions != null) && (typeof this.httprequest.xoptions.tsid == 'number')) { tsid = this.httprequest.xoptions.tsid; }
// Lock the current user out of the desktop
try {
if (process.platform == 'win32') {
MeshServerLogEx(53, null, "Locking remote user out of desktop", this.httprequest);
var child = require('child_process');
child.execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'RunDll32.exe user32.dll,LockWorkStation'], { type: 1, uid: tsid });
}
} catch (ex) { }
}
// If this is a routing session, clean up and send the new session counts. // If this is a routing session, clean up and send the new session counts.
if (this.httprequest.userid != null) { if (this.httprequest.userid != null) {
if (this.httprequest.tcpport != null) { if (this.httprequest.tcpport != null) {
@ -2734,6 +2750,11 @@ function onTunnelControlData(data, ws) {
} catch (e) { } } catch (e) { }
break; break;
} }
case 'autolock': {
// Set the session to auto lock on disconnect
if (obj.value === true) { ws.httprequest.autolock = true; } else { delete ws.httprequest.autolock; }
break;
}
case 'options': { case 'options': {
// These are additional connection options passed in the control channel. // These are additional connection options passed in the control channel.
//sendConsoleText('options: ' + JSON.stringify(obj)); //sendConsoleText('options: ' + JSON.stringify(obj));
@ -2743,6 +2764,9 @@ function onTunnelControlData(data, ws) {
// Set additional user consent options if present // Set additional user consent options if present
if ((obj != null) && (typeof obj.consent == 'number')) { ws.httprequest.consent |= obj.consent; } if ((obj != null) && (typeof obj.consent == 'number')) { ws.httprequest.consent |= obj.consent; }
// Set autolock
if ((obj != null) && (obj.autolock === true)) { ws.httprequest.autolock = true; }
break; break;
} }
case 'close': { case 'close': {

View File

@ -93,6 +93,7 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
obj.recordingFileWriting = false; // Set to true is we are in the process if writing to the recording file. obj.recordingFileWriting = false; // Set to true is we are in the process if writing to the recording file.
obj.startTime = null; // Starting time of the multiplex session. obj.startTime = null; // Starting time of the multiplex session.
obj.userIds = []; // List of userid's that have intertracted with this session. obj.userIds = []; // List of userid's that have intertracted with this session.
//obj.autoLock = false; // Automatically lock the remote device once disconnected
// Accounting // Accounting
parent.trafficStats.desktopMultiplex.sessions++; parent.trafficStats.desktopMultiplex.sessions++;
@ -471,7 +472,10 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
try { json = JSON.parse(data); } catch (ex) { } try { json = JSON.parse(data); } catch (ex) { }
if (json == null) return; if (json == null) return;
if ((json.type == 'options') && (obj.protocolOptions == null)) { obj.protocolOptions = json; } if ((json.type == 'options') && (obj.protocolOptions == null)) { obj.protocolOptions = json; }
if ((json.ctrlChannel == '102938') && (json.type == 'lock') && (viewer.viewOnly == false)) { obj.sendToAgent('{"ctrlChannel":"102938","type":"lock"}'); } // Account lock support if (json.ctrlChannel == '102938') {
if ((json.type == 'lock') && (viewer.viewOnly == false)) { obj.sendToAgent('{"ctrlChannel":"102938","type":"lock"}'); } // Account lock support
if ((json.type == 'autolock') && (viewer.viewOnly == false) && (typeof json.value == 'boolean')) { obj.sendToAgent('{"ctrlChannel":"102938","type":"autolock","value":' + json.value + '}'); } // Lock on disconnect
}
return; return;
} }

View File

@ -1148,6 +1148,12 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr>
<td></td>
<td>
<label style="display:block" id="d7deskAutoLockLabel"><input type="checkbox" id="d7deskAutoLock" />Lock on Disconnect</label>
</td>
</tr>
</table> </table>
</div> </div>
<div id="d7amtkvm"> <div id="d7amtkvm">
@ -3909,7 +3915,7 @@
var desktop; var desktop;
var desktopNode; var desktopNode;
var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50 }; var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50, autolock: false };
function setupDesktop() { function setupDesktop() {
// Setup the remote desktop // Setup the remote desktop
if ((desktopNode != currentNode) && (desktop != null)) { desktop.Stop(); desktopNode = null; desktop = null; } if ((desktopNode != currentNode) && (desktop != null)) { desktop.Stop(); desktopNode = null; desktop = null; }
@ -4015,6 +4021,7 @@
desktop.options = {}; desktop.options = {};
if (tsid != null) { desktop.options.tsid = tsid; } if (tsid != null) { desktop.options.tsid = tsid; }
if (consent != null) { desktop.options.consent = consent; } if (consent != null) { desktop.options.consent = consent; }
if (desktopsettings.autolock == true) { desktop.options.autolock = true; }
desktop.onStateChanged = onDesktopStateChange; desktop.onStateChanged = onDesktopStateChange;
if ((features2 & 0x2000) != 0) desktop.m.stopInput = true; if ((features2 & 0x2000) != 0) desktop.m.stopInput = true;
desktop.onConsoleMessageChange = function () { desktop.onConsoleMessageChange = function () {
@ -4110,11 +4117,13 @@
desktopsettings.quality = d7bitmapquality.value; desktopsettings.quality = d7bitmapquality.value;
desktopsettings.scaling = d7bitmapscaling.value; desktopsettings.scaling = d7bitmapscaling.value;
desktopsettings.framerate = d7framelimiter.value; desktopsettings.framerate = d7framelimiter.value;
desktopsettings.autolock = d7deskAutoLock.checked;
localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings)); localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings));
applyDesktopSettings(); applyDesktopSettings();
if (desktop) { if (desktop) {
if (desktop.contype == 1) { if (desktop.contype == 1) {
if (desktop.State != 0) { desktop.m.SendCompressionLevel(webpSupport?4:1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); } if (desktop.State != 0) { desktop.m.SendCompressionLevel(webpSupport ? 4 : 1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); }
desktop.sendCtrlMsg('{"ctrlChannel":"102938","type":"autolock","value":' + desktopsettings.autolock + '}');
} }
if (desktop.contype == 2) { if (desktop.contype == 2) {
if (desktop.State != 0) { desktop.Stop(); setTimeout(function () { connectDesktop(null, 2); }, 50); } if (desktop.State != 0) { desktop.Stop(); setTimeout(function () { connectDesktop(null, 2); }, 50); }
@ -4131,6 +4140,7 @@
if (ops.indexOf(parseInt(desktopsettings.quality)) >= 0) { d7bitmapquality.value = desktopsettings.quality; } if (ops.indexOf(parseInt(desktopsettings.quality)) >= 0) { d7bitmapquality.value = desktopsettings.quality; }
d7bitmapscaling.value = desktopsettings.scaling; d7bitmapscaling.value = desktopsettings.scaling;
if (desktopsettings.framerate) { d7framelimiter.value = desktopsettings.framerate; } if (desktopsettings.framerate) { d7framelimiter.value = desktopsettings.framerate; }
if (desktopsettings.autolock != null) { d7deskAutoLock.checked = desktopsettings.autolock; }
} }

View File

@ -1252,6 +1252,7 @@
<label style="display:block"><input type="checkbox" id="d7deskSwapMouse" />Swap Mouse Buttons</label> <label style="display:block"><input type="checkbox" id="d7deskSwapMouse" />Swap Mouse Buttons</label>
<label style="display:block"><input type="checkbox" id="d7deskRemoteKeyMap" />Use Remote Keyboard Map</label> <label style="display:block"><input type="checkbox" id="d7deskRemoteKeyMap" />Use Remote Keyboard Map</label>
<label style="display:block" id="d7deskAutoClipboardLabel"><input type="checkbox" id="d7deskAutoClipboard" />Automatic Clipboard</label> <label style="display:block" id="d7deskAutoClipboardLabel"><input type="checkbox" id="d7deskAutoClipboard" />Automatic Clipboard</label>
<label style="display:block" id="d7deskAutoLockLabel"><input type="checkbox" id="d7deskAutoLock" />Lock on Disconnect</label>
</div> </div>
</div> </div>
</div> </div>
@ -1325,7 +1326,7 @@
var stars = {}; // Devices that have been "stared" by the user. var stars = {}; // Devices that have been "stared" by the user.
var nodeShortIdent = 0; var nodeShortIdent = 0;
var desktop; var desktop;
var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50, localkeymap: false, swapmouse: false, remotekeymap: false }; var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50, localkeymap: false, swapmouse: false, remotekeymap: false, autoclipboard: false, autolock: false };
var multidesktopsettings = { quality: 20, scaling: 128, framerate: 1000 }; var multidesktopsettings = { quality: 20, scaling: 128, framerate: 1000 };
var terminal; var terminal;
var files; var files;
@ -7997,6 +7998,7 @@
desktop.options = {}; desktop.options = {};
if (tsid != null) { desktop.options.tsid = tsid; } if (tsid != null) { desktop.options.tsid = tsid; }
if (consent != null) { desktop.options.consent = consent; } if (consent != null) { desktop.options.consent = consent; }
if (desktopsettings.autolock == true) { desktop.options.autolock = true; }
desktop.onStateChanged = onDesktopStateChange; desktop.onStateChanged = onDesktopStateChange;
if ((features2 & 0x2000) != 0) desktop.m.stopInput = true; if ((features2 & 0x2000) != 0) desktop.m.stopInput = true;
desktop.m.onRemoteInputLockChanged = function(obj, state) { QV('DeskInputLockedButton', state); QV('DeskInputUnLockedButton', !state); } desktop.m.onRemoteInputLockChanged = function(obj, state) { QV('DeskInputLockedButton', state); QV('DeskInputUnLockedButton', !state); }
@ -8206,6 +8208,7 @@
desktopsettings.swapmouse = d7deskSwapMouse.checked; desktopsettings.swapmouse = d7deskSwapMouse.checked;
desktopsettings.remotekeymap = d7deskRemoteKeyMap.checked; desktopsettings.remotekeymap = d7deskRemoteKeyMap.checked;
desktopsettings.autoclipboard = d7deskAutoClipboard.checked; desktopsettings.autoclipboard = d7deskAutoClipboard.checked;
desktopsettings.autolock = d7deskAutoLock.checked;
desktopsettings.localkeymap = d7localKeyMap.checked; desktopsettings.localkeymap = d7localKeyMap.checked;
localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings)); localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings));
applyDesktopSettings(); applyDesktopSettings();
@ -8216,6 +8219,7 @@
desktop.m.remoteKeyMap = desktopsettings.remotekeymap; desktop.m.remoteKeyMap = desktopsettings.remotekeymap;
if (desktop.State != 0) { if (desktop.State != 0) {
desktop.m.SendCompressionLevel(webpSupport?4:1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); desktop.m.SendCompressionLevel(webpSupport?4:1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate);
desktop.sendCtrlMsg('{"ctrlChannel":"102938","type":"autolock","value":' + desktopsettings.autolock + '}');
} }
} }
if (desktop.contype == 2) { if (desktop.contype == 2) {
@ -8239,6 +8243,7 @@
if (desktopsettings.swapmouse != null) { d7deskSwapMouse.checked = desktopsettings.swapmouse; } if (desktopsettings.swapmouse != null) { d7deskSwapMouse.checked = desktopsettings.swapmouse; }
if (desktopsettings.remotekeymap != null) { d7deskRemoteKeyMap.checked = desktopsettings.remotekeymap; } if (desktopsettings.remotekeymap != null) { d7deskRemoteKeyMap.checked = desktopsettings.remotekeymap; }
if (desktopsettings.autoclipboard != null) { d7deskAutoClipboard.checked = desktopsettings.autoclipboard; } if (desktopsettings.autoclipboard != null) { d7deskAutoClipboard.checked = desktopsettings.autoclipboard; }
if (desktopsettings.autolock != null) { d7deskAutoLock.checked = desktopsettings.autolock; }
if (desktopsettings.localkeymap) { d7localKeyMap.checked = desktopsettings.localkeymap; } if (desktopsettings.localkeymap) { d7localKeyMap.checked = desktopsettings.localkeymap; }
QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (desktop.state != 0) && (desktopsettings.showfocus)); QV('deskFocusBtn', (desktop != null) && (desktop.contype == 2) && (desktop.state != 0) && (desktopsettings.showfocus));
} }