Relay sessions like SSH and RDP would randomly get stuck at 'Setup...', this is now fixed.
Ylian Saint-Hilaire committed
Aug 3, 2022 at 12:48 UTC
f735693d7568d052bbc0ff6d850f44252b9a7e52
2 files changed
+8
-8
apprelays.js
+4
-4
@@ -836,7 +836,7 @@ module.exports.CreateMstscRelay = function (parent, db, ws, req, args, domain) {
836
rdpClient = require('./rdp').createClient(args).on('connect', function () {
837
send(['rdp-connect']);
838
if ((typeof obj.infos.options == 'object') && (obj.infos.options.savepass == true)) { saveRdpCredentials(); } // Save the credentials if needed
839
- obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64');
839
+ obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
840
obj.startTime = Date.now();
841
842
// Event session start
@@ -1173,7 +1173,7 @@ module.exports.CreateSshRelay = function (parent, db, ws, req, args, domain) {
1173
obj.sshClient.on('ready', function () { // Authentication was successful.
1174
// If requested, save the credentials
1175
saveSshCredentials(obj.keep);
1176
- obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64');
1176
+ obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
1177
obj.startTime = Date.now();
1178
1179
// Event start of session
@@ -1512,7 +1512,7 @@ module.exports.CreateSshTerminalRelay = function (parent, db, ws, req, domain, u
1512
obj.sshClient.on('ready', function () { // Authentication was successful.
1513
// If requested, save the credentials
1514
saveSshCredentials(obj.keep);
1515
- obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64');
1515
+ obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
1516
obj.startTime = Date.now();
1517
1518
try {
@@ -1866,7 +1866,7 @@ module.exports.CreateSshFilesRelay = function (parent, db, ws, req, domain, user
1866
obj.sshClient.on('ready', function () { // Authentication was successful.
1867
// If requested, save the credentials
1868
saveSshCredentials(obj.keep);
1869
- obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64');
1869
+ obj.sessionid = Buffer.from(parent.crypto.randomBytes(9), 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
1870
obj.startTime = Date.now();
1871
1872
// Event start of session
meshrelay.js
+4
-4
@@ -879,7 +879,7 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
879
const rcookieData = {};
880
if (user != null) { rcookieData.ruserid = user._id; } else if (obj.nouser === true) { rcookieData.nouser = 1; }
881
const rcookie = parent.parent.encodeCookie(rcookieData, parent.parent.loginCookieEncryptionKey);
882
- if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64'); } // If there is no connection id, generate one.
882
+ if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64').replace(/\+/g, '@').replace(/\//g, '$'); } // If there is no connection id, generate one.
883
const command = { nodeid: cookie.nodeid, action: 'msg', type: 'tunnel', value: '*/' + xdomain + 'meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, tcpport: cookie.tcpport, tcpaddr: cookie.tcpaddr, soptions: {} };
884
if (user) { command.userid = user._id; }
885
if (typeof domain.consentmessages == 'object') {
@@ -915,7 +915,7 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
915
obj.meshid = node.meshid;
916
917
// Send connection request to agent
918
- if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64'); } // If there is no connection id, generate one.
918
+ if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64').replace(/\+/g, '@').replace(/\//g, '$'); } // If there is no connection id, generate one.
919
const rcookie = parent.parent.encodeCookie({ ruserid: user._id }, parent.parent.loginCookieEncryptionKey);
920
if (obj.req.query.tcpport != null) {
921
const command = { nodeid: obj.req.query.nodeid, action: 'msg', type: 'tunnel', userid: user._id, value: '*/' + xdomain + 'meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, tcpport: obj.req.query.tcpport, tcpaddr: ((obj.req.query.tcpaddr == null) ? '127.0.0.1' : obj.req.query.tcpaddr), soptions: {} };
@@ -971,7 +971,7 @@ function CreateMeshRelayEx(parent, ws, req, domain, user, cookie) {
971
obj.meshid = node.meshid;
972
973
// Send connection request to agent
974
- if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64'); } // If there is no connection id, generate one.
974
+ if (obj.id == null) { obj.id = parent.crypto.randomBytes(9).toString('base64').replace(/\+/g, '@').replace(/\//g, '$'); } // If there is no connection id, generate one.
975
const rcookieData = { nodeid: node._id };
976
if (user != null) { rcookieData.ruserid = user._id; } else if (obj.nouser === true) { rcookieData.nouser = 1; }
977
const rcookie = parent.parent.encodeCookie(rcookieData, parent.parent.loginCookieEncryptionKey);
@@ -1117,7 +1117,7 @@ module.exports.CreateLocalRelay = function (parent, ws, req, domain, user, cooki
1117
function CreateLocalRelayEx(parent, ws, req, domain, user, cookie) {
1118
const net = require('net');
1119
var obj = {};
1120
- obj.id = parent.crypto.randomBytes(9).toString('base64');
1120
+ obj.id = parent.crypto.randomBytes(9).toString('base64').replace(/\+/g, '@').replace(/\//g, '$');
1121
obj.req = req;
1122
obj.ws = ws;
1123
obj.user = user;