Fixed guest sessions not being reported correctly by agents.

Ylian Saint-Hilaire committed Feb 23, 2022 at 17:17 UTC 320aa6f40ce547b96a11ff610c01a2dd1a7b053d
3 files changed +5 -4
agents/meshcore.js
+3 -2
@@ -1012,7 +1012,7 @@ function handleServerCommand(data) {
1012 woptions.checkServerIdentity.servertlshash = data.servertlshash;
1013
1014 //sendConsoleText(JSON.stringify(woptions));
1015 - //sendConsoleText('TUNNEL: ' + JSON.stringify(data));
1015 + //sendConsoleText('TUNNEL: ' + JSON.stringify(data, null, 2));
1016 var tunnel = http.request(woptions);
1017 tunnel.upgrade = onTunnelUpgrade;
1018 tunnel.on('error', function (e) { sendConsoleText("ERROR: Unable to connect relay tunnel to: " + this.url + ", " + JSON.stringify(e)); });
@@ -1023,6 +1023,7 @@ function handleServerCommand(data) {
1023 tunnel.privacybartext = data.privacybartext ? data.privacybartext : currentTranslation['privacyBar'];
1024 tunnel.username = data.username + (data.guestname ? (' - ' + data.guestname) : '');
1025 tunnel.realname = (data.realname ? data.realname : data.username) + (data.guestname ? (' - ' + data.guestname) : '');
1026 + tunnel.guestuserid = data.guestuserid;
1027 tunnel.guestname = data.guestname;
1028 tunnel.userid = data.userid;
1029 if (server_check_consentTimer(tunnel.userid)) { tunnel.consent = (tunnel.consent & -57); } // Deleting Consent Requirement
@@ -1828,7 +1829,7 @@ function onTunnelUpgrade(response, s, head) {
1829 // If the HTTP Request has a guest name, we need to form a userid that includes the guest name in hex.
1830 // This is so we can tell the server that a session is for a given userid/guest sharing pair.
1831 function getUserIdAndGuestNameFromHttpRequest(request) {
1831 - if (request.guestname == null) return request.userid; else return request.userid + '/guest:' + Buffer.from(request.guestname).toString('base64');
1832 + if (request.guestname == null) return request.userid; else return request.guestuserid + '/guest:' + Buffer.from(request.guestname).toString('base64');
1833 }
1834
1835 // Called when UDP relay data is received // TODO****
meshdesktopmultiplex.js
+1 -1
@@ -1333,7 +1333,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) {
1333 const rcookieData = { nodeid: node._id };
1334 if (user != null) { rcookieData.ruserid = user._id; } else if (obj.nouser === true) { rcookieData.nouser = 1; }
1335 const rcookie = parent.parent.encodeCookie(rcookieData, parent.parent.loginCookieEncryptionKey);
1336 - const command = { nodeid: node._id, action: 'msg', type: 'tunnel', value: '*/meshrelay.ashx?p=2&id=' + obj.id + '&rauth=' + rcookie + '&nodeid=' + node._id, soptions: {}, usage: 2, rights: cookie.r, guestname: cookie.gn, consent: cookie.cf, remoteaddr: cleanRemoteAddr(obj.req.clientIp) };
1336 + const command = { nodeid: node._id, action: 'msg', type: 'tunnel', value: '*/meshrelay.ashx?p=2&id=' + obj.id + '&rauth=' + rcookie + '&nodeid=' + node._id, soptions: {}, usage: 2, rights: cookie.r, guestuserid: user._id, guestname: cookie.gn, consent: cookie.cf, remoteaddr: cleanRemoteAddr(obj.req.clientIp) };
1337 if (typeof domain.consentmessages == 'object') {
1338 if (typeof domain.consentmessages.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
1339 if (typeof domain.consentmessages.desktop == 'string') { command.soptions.consentMsgDesktop = domain.consentmessages.desktop; }
meshrelay.js
+1 -1
@@ -971,7 +971,7 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
971 const rcookieData = { nodeid: node._id };
972 if (user != null) { rcookieData.ruserid = user._id; } else if (obj.nouser === true) { rcookieData.nouser = 1; }
973 const rcookie = parent.parent.encodeCookie(rcookieData, parent.parent.loginCookieEncryptionKey);
974 - const command = { nodeid: node._id, action: 'msg', type: 'tunnel', value: '*/' + xdomain + 'meshrelay.ashx?p=' + obj.req.query.p + '&id=' + obj.id + '&rauth=' + rcookie + '&nodeid=' + node._id, soptions: {}, rights: cookie.r, guestname: cookie.gn, consent: cookie.cf, remoteaddr: cleanRemoteAddr(obj.req.clientIp) };
974 + const command = { nodeid: node._id, action: 'msg', type: 'tunnel', value: '*/' + xdomain + 'meshrelay.ashx?p=' + obj.req.query.p + '&id=' + obj.id + '&rauth=' + rcookie + '&nodeid=' + node._id, soptions: {}, rights: cookie.r, guestuserid: user._id, guestname: cookie.gn, consent: cookie.cf, remoteaddr: cleanRemoteAddr(obj.req.clientIp) };
975 obj.guestname = cookie.gn;
976
977 // Limit what this relay connection can do