1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-02-12 11:01:52 +00:00

Fixed Web-RDP when used with non-default domain (#4271)

This commit is contained in:
Ylian Saint-Hilaire 2022-07-14 15:18:41 -07:00
parent 410ead461d
commit acb9a5bb6e
4 changed files with 10 additions and 8 deletions

View file

@ -775,7 +775,8 @@ module.exports.CreateMstscRelay = function (parent, db, ws, req, args, domain) {
const protocol = (args.tlsoffload) ? 'ws' : 'wss'; const protocol = (args.tlsoffload) ? 'ws' : 'wss';
var domainadd = ''; var domainadd = '';
if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' } if ((domain.dns == null) && (domain.id != '')) { domainadd = domain.id + '/' }
const url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=10&auth=' + obj.infos.ip; // Protocol 10 is Web-RDP var url = protocol + '://localhost:' + args.port + '/' + domainadd + (((obj.mtype == 3) && (obj.relaynodeid == null)) ? 'local' : 'mesh') + 'relay.ashx?p=10&auth=' + obj.infos.ip; // Protocol 10 is Web-RDP
if (domain.id != '') { url += '&domainid=' + domain.id; } // Since we are using "localhost", we are going to signal what domain we are on using a URL argument.
parent.parent.debug('relay', 'RDP: Connection websocket to ' + url); parent.parent.debug('relay', 'RDP: Connection websocket to ' + url);
obj.wsClient = new WebSocket(url, options); obj.wsClient = new WebSocket(url, options);
obj.wsClient.on('open', function () { parent.parent.debug('relay', 'RDP: Relay websocket open'); }); obj.wsClient.on('open', function () { parent.parent.debug('relay', 'RDP: Relay websocket open'); });

View file

@ -5,9 +5,9 @@
*/ */
// Construct a RDP remote desktop object // Construct a RDP remote desktop object
var CreateRDPDesktop = function (canvasid) { var CreateRDPDesktop = function (canvasid, domainUrl) {
var obj = {} var obj = {}
obj.m = { KeyAction: { "NONE": 0, "DOWN": 1, "UP": 2, "SCROLL": 3, "EXUP": 4, "EXDOWN": 5, "DBLCLICK": 6 } }; obj.m = { KeyAction: { 'NONE': 0, 'DOWN': 1, 'UP': 2, 'SCROLL': 3, 'EXUP': 4, 'EXDOWN': 5, 'DBLCLICK': 6 } };
obj.State = 0; obj.State = 0;
obj.canvas = Q(canvasid); obj.canvas = Q(canvasid);
obj.CanvasId = canvasid; obj.CanvasId = canvasid;
@ -41,7 +41,7 @@ var CreateRDPDesktop = function (canvasid) {
delete credentials.height; delete credentials.height;
} }
obj.render = new Mstsc.Canvas.create(obj.canvas); obj.render = new Mstsc.Canvas.create(obj.canvas);
obj.socket = new WebSocket('wss://' + window.location.host + '/mstscrelay.ashx'); // TODO: Support domains obj.socket = new WebSocket('wss://' + window.location.host + domainUrl + 'mstscrelay.ashx');
obj.socket.binaryType = 'arraybuffer'; obj.socket.binaryType = 'arraybuffer';
obj.socket.onopen = function () { obj.socket.onopen = function () {
changeState(2); // Setup state changeState(2); // Setup state

View file

@ -8686,7 +8686,7 @@
meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id, tag: consent }); meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id, tag: consent });
} else if (contype == 4) { } else if (contype == 4) {
// Setup RDP remote desktop // Setup RDP remote desktop
desktop = CreateRDPDesktop('Desk'); desktop = CreateRDPDesktop('Desk', domainUrl);
desktop.onStateChanged = onDesktopStateChange; desktop.onStateChanged = onDesktopStateChange;
desktop.m.onScreenSizeChange = mdeskAdjust; desktop.m.onScreenSizeChange = mdeskAdjust;
desktop.m.onClipboardChanged = function(text) { if ((text != null) && (desktopsettings.rdpautoclipboard) && (navigator.clipboard != null)) { navigator.clipboard.writeText(text).then(function() { }).catch(function(err) { console.log(err); }) } } // Put remote clipboard data into our clipboard desktop.m.onClipboardChanged = function(text) { if ((text != null) && (desktopsettings.rdpautoclipboard) && (navigator.clipboard != null)) { navigator.clipboard.writeText(text).then(function() { }).catch(function(err) { console.log(err); }) } } // Put remote clipboard data into our clipboard

View file

@ -754,10 +754,11 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
// Request or connection says open regardless of the response // Request or connection says open regardless of the response
function getDomain(req) { function getDomain(req) {
if (req.xdomain != null) { return req.xdomain; } // Domain already set for this request, return it. if (req.xdomain != null) { return req.xdomain; } // Domain already set for this request, return it.
if (req.headers.host != null) { var d = obj.dnsDomains[req.headers.host.split(':')[0].toLowerCase()]; if (d != null) return d; } // If this is a DNS name domain, return it here. if ((req.hostname == 'localhost') && (req.query.domainid != null)) { const d = parent.config.domains[req.query.domainid]; if (d != null) return d; } // This is a localhost access with the domainid specified in the URL
var x = req.url.split('/'); if (req.hostname != null) { const d = obj.dnsDomains[req.hostname.toLowerCase()]; if (d != null) return d; } // If this is a DNS name domain, return it here.
const x = req.url.split('/');
if (x.length < 2) return parent.config.domains['']; if (x.length < 2) return parent.config.domains[''];
var y = parent.config.domains[x[1].toLowerCase()]; const y = parent.config.domains[x[1].toLowerCase()];
if ((y != null) && (y.dns == null)) { return parent.config.domains[x[1].toLowerCase()]; } if ((y != null) && (y.dns == null)) { return parent.config.domains[x[1].toLowerCase()]; }
return parent.config.domains['']; return parent.config.domains[''];
} }