Added relay mapping support to deviceMeshRouterLinks.

This commit is contained in:
Ylian Saint-Hilaire 2021-03-04 17:03:25 -08:00
parent e7da82684f
commit f2bebe004d
4 changed files with 10 additions and 3 deletions

View File

@ -248,6 +248,10 @@
"description": "The port on the remote device.", "description": "The port on the remote device.",
"type": "number" "type": "number"
}, },
"ip": {
"description": "Target IP address. If not specified, the target of the connection is the remote device running the MeshAgent.",
"type": "string"
},
"filter": { "filter": {
"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.", "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.",
"type": "array", "type": "array",

View File

@ -4160,6 +4160,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (command.nodeid) { cookieContent.nodeid = command.nodeid; } if (command.nodeid) { cookieContent.nodeid = command.nodeid; }
if (command.tcpaddr) { cookieContent.tcpaddr = command.tcpaddr; } // Indicates the browser want to agent to TCP connect to a remote address if (command.tcpaddr) { cookieContent.tcpaddr = command.tcpaddr; } // Indicates the browser want to agent to TCP connect to a remote address
if (command.tcpport) { cookieContent.tcpport = command.tcpport; } // Indicates the browser want to agent to TCP connect to a remote port if (command.tcpport) { cookieContent.tcpport = command.tcpport; } // Indicates the browser want to agent to TCP connect to a remote port
if (command.ip) { cookieContent.ip = command.ip; } // Indicates the browser want to agent to relay a TCP connection to a IP:port
command.cookie = parent.parent.encodeCookie(cookieContent, parent.parent.loginCookieEncryptionKey); command.cookie = parent.parent.encodeCookie(cookieContent, parent.parent.loginCookieEncryptionKey);
command.trustedCert = parent.isTrustedCert(domain); command.trustedCert = parent.isTrustedCert(domain);
try { ws.send(JSON.stringify(command)); } catch (ex) { } try { ws.send(JSON.stringify(command)); } catch (ex) { }

View File

@ -158,6 +158,7 @@
"name": "HTTP", "name": "HTTP",
"protocol": "http", "protocol": "http",
"port": 80, "port": 80,
"_ip": "192.168.1.100",
"_filter": [ "mesh//xxxx", "node//xxxx" ] "_filter": [ "mesh//xxxx", "node//xxxx" ]
}, },
{ {

View File

@ -2419,6 +2419,7 @@
var url = 'mcrouter://' + servername + portStr + domainUrl + 'control.ashx?c=' + authCookie + '&t=' + serverinfo.tlshash + '&l={{{lang}}}' + (urlargs.key?('&key=' + urlargs.key):''); var url = 'mcrouter://' + servername + portStr + domainUrl + 'control.ashx?c=' + authCookie + '&t=' + serverinfo.tlshash + '&l={{{lang}}}' + (urlargs.key?('&key=' + urlargs.key):'');
if (message.nodeid != null) { url += ('&nodeid=' + message.nodeid); } if (message.nodeid != null) { url += ('&nodeid=' + message.nodeid); }
if (message.tcpport != null) { url += ('&protocol=1&remoteport=' + message.tcpport); } if (message.tcpport != null) { url += ('&protocol=1&remoteport=' + message.tcpport); }
if (message.ip != null) { url += ('&remoteip=' + message.ip); }
url += ('&appid=' + message.protocol + '&autoexit=1'); // Protocol: 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP url += ('&appid=' + message.protocol + '&autoexit=1'); // Protocol: 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP
downloadFile(url, ''); downloadFile(url, '');
} else if (message.tag == 'novnc') { } else if (message.tag == 'novnc') {
@ -6146,7 +6147,7 @@
var r = serverinfo.devicemeshrouterlinks.extralinks[i], p = 0; var r = serverinfo.devicemeshrouterlinks.extralinks[i], p = 0;
if ((r.filter == null) || (Array.isArray(r.filter) && ((r.filter.indexOf(mesh._id) >= 0) || (r.filter.indexOf(node._id) >= 0)))) { if ((r.filter == null) || (Array.isArray(r.filter) && ((r.filter.indexOf(mesh._id) >= 0) || (r.filter.indexOf(node._id) >= 0)))) {
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; } 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; }
x += '<a href=# onclick=p10MCRouter("' + node._id + '",' + p + ',' + r.port + ') title="' + "Requires installation of MeshCentral Router." + '">' + r.name + '</a>&nbsp;'; x += '<a href=# onclick=p10MCRouter("' + node._id + '",' + p + ',' + r.port + (r.ip?(',\"' + r.ip + '\"'):'') + ') title="' + "Requires installation of MeshCentral Router." + '">' + r.name + '</a>&nbsp;';
} }
} }
} }
@ -6820,9 +6821,9 @@
meshserver.send({ action: 'removedevices', nodeids: [ nodeid ] }); meshserver.send({ action: 'removedevices', nodeids: [ nodeid ] });
} }
function p10MCRouter(nodeid, protocol, port) { function p10MCRouter(nodeid, protocol, port, ip) {
if ((protocol == 3) && (port == null)) { if (currentNode.rdpport != null) { port = currentNode.rdpport; } else { port = 3389; } } if ((protocol == 3) && (port == null)) { if (currentNode.rdpport != null) { port = currentNode.rdpport; } else { port = 3389; } }
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 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
return false; return false;
} }