Disconnect desktop from User-side using Privay bar

If 'privacy bar' user consent option is enabled for desktop, then it will show the privacy bar in user side while taking desktop access. But it will not disconnect the session even though clicks the close option. It will only close the privacy bar. This issue is fixed. https://github.com/Ylianst/MeshCentral/issues/5289

Abarna512 committed Oct 5, 2023 at 16:35 UTC a397d9a79a0dfbd86903484a7c6a80efd9922276
1 file changed +16 -19
agents/meshcore.js
+16 -19
@@ -2565,27 +2565,24 @@ function kvm_consentpromise_resolved(always)
2565 MeshServerLogEx(32, null, "Remote Desktop Connection Bar Failed or Not Supported (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
2566 }
2567 }
2568 - if (this.ws.httprequest.desktop.kvm.connectionBar)
2568 + try {
2569 + if (this.ws.httprequest.desktop.kvm.connectionBar) {
2570 + this.ws.httprequest.desktop.kvm.connectionBar.httprequest = this.ws.httprequest;
2571 + this.ws.httprequest.desktop.kvm.connectionBar.on('close', function () {
2572 + MeshServerLogEx(29, null, "Remote Desktop Connection forcefully closed by local user (" + this.httprequest.remoteaddr + ")", this.httprequest);
2573 + for (var i in this.httprequest.desktop.kvm._pipedStreams) {
2574 + this.httprequest.desktop.kvm._pipedStreams[i].end();
2575 + }
2576 + this.httprequest.desktop.kvm.end();
2577 + });
2578 + }
2579 + }
2580 + catch (ex)
2581 {
2570 - this.ws.httprequest.desktop.kvm.connectionBar.state =
2571 - {
2572 - userid: this.ws.httprequest.userid,
2573 - xuserid: this.ws.httprequest.xuserid,
2574 - username: this.ws.httprequest.username,
2575 - sessionid: this.ws.httprequest.sessionid,
2576 - remoteaddr: this.ws.httprequest.remoteaddr,
2577 - guestname: this.ws.httprequest.guestname,
2578 - desktop: this.ws.httprequest.desktop
2579 - };
2580 - this.ws.httprequest.desktop.kvm.connectionBar.on('close', function ()
2582 + if (process.platform != 'darwin')
2583 {
2582 - MeshServerLogEx(29, null, "Remote Desktop Connection forcefully closed by local user (" + this.state.remoteaddr + ")", state);
2583 - for (var i in this.state.desktop.kvm._pipedStreams)
2584 - {
2585 - this.state.desktop.kvm._pipedStreams[i].end();
2586 - }
2587 - this.state.desktop.kvm.end();
2588 - });
2584 + MeshServerLogEx(32, null, "Failed2(" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
2585 + }
2586 }
2587 }
2588 this.ws.httprequest.desktop.kvm.pipe(this.ws, { dataTypeSkip: 1 });