Fixed Web-RDP when used with non-default domain (#4271)
This commit is contained in:
parent
410ead461d
commit
acb9a5bb6e
|
@ -775,7 +775,8 @@ module.exports.CreateMstscRelay = function (parent, db, ws, req, args, domain) {
|
|||
const protocol = (args.tlsoffload) ? 'ws' : 'wss';
|
||||
var domainadd = '';
|
||||
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);
|
||||
obj.wsClient = new WebSocket(url, options);
|
||||
obj.wsClient.on('open', function () { parent.parent.debug('relay', 'RDP: Relay websocket open'); });
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
*/
|
||||
|
||||
// Construct a RDP remote desktop object
|
||||
var CreateRDPDesktop = function (canvasid) {
|
||||
var CreateRDPDesktop = function (canvasid, domainUrl) {
|
||||
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.canvas = Q(canvasid);
|
||||
obj.CanvasId = canvasid;
|
||||
|
@ -41,7 +41,7 @@ var CreateRDPDesktop = function (canvasid) {
|
|||
delete credentials.height;
|
||||
}
|
||||
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.onopen = function () {
|
||||
changeState(2); // Setup state
|
||||
|
|
|
@ -8686,7 +8686,7 @@
|
|||
meshserver.send({ action: 'msg', type: 'userSessions', nodeid: currentNode._id, tag: consent });
|
||||
} else if (contype == 4) {
|
||||
// Setup RDP remote desktop
|
||||
desktop = CreateRDPDesktop('Desk');
|
||||
desktop = CreateRDPDesktop('Desk', domainUrl);
|
||||
desktop.onStateChanged = onDesktopStateChange;
|
||||
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
|
||||
|
|
|
@ -754,10 +754,11 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
|
|||
// Request or connection says open regardless of the response
|
||||
function getDomain(req) {
|
||||
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.
|
||||
var x = req.url.split('/');
|
||||
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
|
||||
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[''];
|
||||
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()]; }
|
||||
return parent.config.domains[''];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue