Added relay mapping support to deviceMeshRouterLinks.

Ylian Saint-Hilaire committed Mar 4, 2021 at 17:03 UTC f2bebe004d36f5987cd1e6ae54b2c851b9674440
4 files changed +10 -3
meshcentral-config-schema.json
+4
@@ -248,6 +248,10 @@
248 "description": "The port on the remote device.",
249 "type": "number"
250 },
251 + "ip": {
252 + "description": "Target IP address. If not specified, the target of the connection is the remote device running the MeshAgent.",
253 + "type": "string"
254 + },
255 "filter": {
256 "description": "Array of node/domain/id or mesh/domain/id strings. When set, the link will only show up for the specified devices or device groups.",
257 "type": "array",
meshuser.js
+1
@@ -4160,6 +4160,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4160 if (command.nodeid) { cookieContent.nodeid = command.nodeid; }
4161 if (command.tcpaddr) { cookieContent.tcpaddr = command.tcpaddr; } // Indicates the browser want to agent to TCP connect to a remote address
4162 if (command.tcpport) { cookieContent.tcpport = command.tcpport; } // Indicates the browser want to agent to TCP connect to a remote port
4163 + if (command.ip) { cookieContent.ip = command.ip; } // Indicates the browser want to agent to relay a TCP connection to a IP:port
4164 command.cookie = parent.parent.encodeCookie(cookieContent, parent.parent.loginCookieEncryptionKey);
4165 command.trustedCert = parent.isTrustedCert(domain);
4166 try { ws.send(JSON.stringify(command)); } catch (ex) { }
sample-config-advanced.json
+1
@@ -158,6 +158,7 @@
158 "name": "HTTP",
159 "protocol": "http",
160 "port": 80,
161 + "_ip": "192.168.1.100",
162 "_filter": [ "mesh//xxxx", "node//xxxx" ]
163 },
164 {
views/default.handlebars
+4 -3
@@ -2419,6 +2419,7 @@
2419 var url = 'mcrouter://' + servername + portStr + domainUrl + 'control.ashx?c=' + authCookie + '&t=' + serverinfo.tlshash + '&l={{{lang}}}' + (urlargs.key?('&key=' + urlargs.key):'');
2420 if (message.nodeid != null) { url += ('&nodeid=' + message.nodeid); }
2421 if (message.tcpport != null) { url += ('&protocol=1&remoteport=' + message.tcpport); }
2422 + if (message.ip != null) { url += ('&remoteip=' + message.ip); }
2423 url += ('&appid=' + message.protocol + '&autoexit=1'); // Protocol: 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP
2424 downloadFile(url, '');
2425 } else if (message.tag == 'novnc') {
@@ -6146,7 +6147,7 @@
6147 var r = serverinfo.devicemeshrouterlinks.extralinks[i], p = 0;
6148 if ((r.filter == null) || (Array.isArray(r.filter) && ((r.filter.indexOf(mesh._id) >= 0) || (r.filter.indexOf(node._id) >= 0)))) {
6149 if (typeof r.protocol == 'number') { p = r.protocol; } else if (r.protocol == 'http') { p = 1; } else if (r.protocol == 'https') { p = 2; } else if (r.protocol == 'rdp') { p = 3; } else if (r.protocol == 'ssh') { p = 4; } else if (r.protocol == 'scp') { p = 5; }
6149 - x += '<a href=# onclick=p10MCRouter("' + node._id + '",' + p + ',' + r.port + ') title="' + "Requires installation of MeshCentral Router." + '">' + r.name + '</a>&nbsp;';
6150 + x += '<a href=# onclick=p10MCRouter("' + node._id + '",' + p + ',' + r.port + (r.ip?(',\"' + r.ip + '\"'):'') + ') title="' + "Requires installation of MeshCentral Router." + '">' + r.name + '</a>&nbsp;';
6151 }
6152 }
6153 }
@@ -6820,9 +6821,9 @@
6821 meshserver.send({ action: 'removedevices', nodeids: [ nodeid ] });
6822 }
6823
6823 - function p10MCRouter(nodeid, protocol, port) {
6824 + function p10MCRouter(nodeid, protocol, port, ip) {
6825 if ((protocol == 3) && (port == null)) { if (currentNode.rdpport != null) { port = currentNode.rdpport; } else { port = 3389; } }
6825 - meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, tag: 'MCRouter', protocol: protocol }); // Protocol: 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP
6826 + meshserver.send({ action: 'getcookie', nodeid: nodeid, tcpport: port, ip: ip, tag: 'MCRouter', protocol: protocol }); // Protocol: 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP
6827 return false;
6828 }
6829