fix remoteaddr null in consent disconnect #6290

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
si458 2024-08-27 10:46:25 +01:00
parent d2d9f7a13e
commit e1e59953f4

View File

@ -2616,11 +2616,14 @@ function kvm_tunnel_consentpromise_closehandler()
function kvm_consentpromise_rejected(e) function kvm_consentpromise_rejected(e)
{ {
// User Consent Denied/Failed if (this.ws) {
this.ws._consentpromise = null; if(this.ws.httprequest){ // User Consent Denied
MeshServerLogEx(34, null, "Failed to start remote desktop after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest); MeshServerLogEx(34, null, "Failed to start remote desktop after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 })); } else { } // Connection was closed server side, maybe log some messages somewhere?
this.ws = null; this.ws._consentpromise = null;
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 }));
this.ws = null;
} else { } // no websocket, maybe log some messages somewhere?
} }
function kvm_consentpromise_resolved(always) function kvm_consentpromise_resolved(always)
{ {
@ -2715,11 +2718,14 @@ function files_consentpromise_resolved(always)
} }
function files_consentpromise_rejected(e) function files_consentpromise_rejected(e)
{ {
// User Consent Denied/Failed if (this.ws) {
this.ws._consentpromise = null; if(this.ws.httprequest){ // User Consent Denied
MeshServerLogEx(41, null, "Failed to start remote files after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest); MeshServerLogEx(41, null, "Failed to start remote files after local user rejected (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 })); } else { } // Connection was closed server side, maybe log some messages somewhere?
this.ws = null; this.ws._consentpromise = null;
this.ws.end(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 }));
this.ws = null;
} else { } // no websocket, maybe log some messages somewhere?
} }
function files_tunnel_endhandler() function files_tunnel_endhandler()
{ {
@ -2867,10 +2873,13 @@ function onTunnelData(data)
this.retPromise._res(); this.retPromise._res();
}, },
function (e) { function (e) {
// Denied if (this.retPromise.that) {
MeshServerLogEx(28, null, "Local user rejected remote terminal request (" + this.retPromise.that.httprequest.remoteaddr + ")", this.retPromise.that.httprequest); if(this.retPromise.that.httprequest){ // User Consent Denied
this.retPromise.that.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 })); MeshServerLogEx(28, null, "Local user rejected remote terminal request (" + this.retPromise.that.httprequest.remoteaddr + ")", this.retPromise.that.httprequest);
this.retPromise._consent = null; } else { } // Connection was closed server side, maybe log some messages somewhere?
this.retPromise._consent = null;
this.retPromise.that.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString(), msgid: 2 }));
} else { } // no websocket, maybe log some messages somewhere?
this.retPromise._rej(e.toString()); this.retPromise._rej(e.toString());
}); });
} }