mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-23 14:01:43 +03:00
Added TCP/UDP routing indication.
This commit is contained in:
parent
aef4575782
commit
ddcbee0cc4
@ -341,7 +341,7 @@ function createMeshCore(agent) {
|
|||||||
var nextTunnelIndex = 1;
|
var nextTunnelIndex = 1;
|
||||||
var amtPolicy = null;
|
var amtPolicy = null;
|
||||||
var apftunnel = null;
|
var apftunnel = null;
|
||||||
var tunnelUserCount = { terminal: {}, files: {} }; // List of userid->count sessions for terminal and files.
|
var tunnelUserCount = { terminal: {}, files: {}, tcp: {}, udp: {} }; // List of userid->count sessions for terminal, files and TCP/UDP routing
|
||||||
|
|
||||||
// Add to the server event log
|
// Add to the server event log
|
||||||
function MeshServerLog(msg, state) {
|
function MeshServerLog(msg, state) {
|
||||||
@ -1127,7 +1127,6 @@ function createMeshCore(agent) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//sendConsoleText('onTunnelUpgrade - ' + this.tcpport + ' - ' + this.udpport);
|
//sendConsoleText('onTunnelUpgrade - ' + this.tcpport + ' - ' + this.udpport);
|
||||||
|
|
||||||
if (this.tcpport != null) {
|
if (this.tcpport != null) {
|
||||||
@ -1138,6 +1137,12 @@ function createMeshCore(agent) {
|
|||||||
if (this.tcpaddr != null) { connectionOptions.host = this.tcpaddr; } else { connectionOptions.host = '127.0.0.1'; }
|
if (this.tcpaddr != null) { connectionOptions.host = this.tcpaddr; } else { connectionOptions.host = '127.0.0.1'; }
|
||||||
s.tcprelay = net.createConnection(connectionOptions, onTcpRelayTargetTunnelConnect);
|
s.tcprelay = net.createConnection(connectionOptions, onTcpRelayTargetTunnelConnect);
|
||||||
s.tcprelay.peerindex = this.index;
|
s.tcprelay.peerindex = this.index;
|
||||||
|
|
||||||
|
// Add the TCP session to the count and update the server
|
||||||
|
if (s.httprequest.userid != null) {
|
||||||
|
if (tunnelUserCount.tcp[s.httprequest.userid] == null) { tunnelUserCount.tcp[s.httprequest.userid] = 1; } else { tunnelUserCount.tcp[s.httprequest.userid]++; }
|
||||||
|
try { mesh.SendCommand({ action: 'sessions', type: 'tcp', value: tunnelUserCount.tcp }); } catch (ex) { }
|
||||||
|
}
|
||||||
} if (this.udpport != null) {
|
} if (this.udpport != null) {
|
||||||
// This is a UDP relay connection, get the UDP socket setup. // TODO: ***************
|
// This is a UDP relay connection, get the UDP socket setup. // TODO: ***************
|
||||||
s.data = onUdpRelayServerTunnelData;
|
s.data = onUdpRelayServerTunnelData;
|
||||||
@ -1148,6 +1153,12 @@ function createMeshCore(agent) {
|
|||||||
s.udprelay.udpport = this.udpport;
|
s.udprelay.udpport = this.udpport;
|
||||||
s.udprelay.udpaddr = this.udpaddr;
|
s.udprelay.udpaddr = this.udpaddr;
|
||||||
s.udprelay.first = true;
|
s.udprelay.first = true;
|
||||||
|
|
||||||
|
// Add the UDP session to the count and update the server
|
||||||
|
if (s.httprequest.userid != null) {
|
||||||
|
if (tunnelUserCount.udp[s.httprequest.userid] == null) { tunnelUserCount.udp[s.httprequest.userid] = 1; } else { tunnelUserCount.udp[s.httprequest.userid]++; }
|
||||||
|
try { mesh.SendCommand({ action: 'sessions', type: 'udp', value: tunnelUserCount.tcp }); } catch (ex) { }
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// This is a normal connect for KVM/Terminal/Files
|
// This is a normal connect for KVM/Terminal/Files
|
||||||
s.data = onTunnelData;
|
s.data = onTunnelData;
|
||||||
@ -1189,6 +1200,17 @@ function createMeshCore(agent) {
|
|||||||
var tunnel = tunnels[this.httprequest.index];
|
var tunnel = tunnels[this.httprequest.index];
|
||||||
if (tunnel == null) return; // Stop duplicate calls.
|
if (tunnel == null) return; // Stop duplicate calls.
|
||||||
|
|
||||||
|
// If this is a routing session, clean up and send the new session counts.
|
||||||
|
if (this.httprequest.userid != null) {
|
||||||
|
if (this.httprequest.tcpport != null) {
|
||||||
|
if (tunnelUserCount.tcp[this.httprequest.userid] != null) { tunnelUserCount.tcp[this.httprequest.userid]--; if (tunnelUserCount.tcp[this.httprequest.userid] <= 0) { delete tunnelUserCount.tcp[this.httprequest.userid]; } }
|
||||||
|
try { mesh.SendCommand({ action: 'sessions', type: 'tcp', value: tunnelUserCount.tcp }); } catch (ex) { }
|
||||||
|
} else if (this.httprequest.udpport != null) {
|
||||||
|
if (tunnelUserCount.udp[this.httprequest.userid] != null) { tunnelUserCount.udp[this.httprequest.userid]--; if (tunnelUserCount.udp[this.httprequest.userid] <= 0) { delete tunnelUserCount.udp[this.httprequest.userid]; } }
|
||||||
|
try { mesh.SendCommand({ action: 'sessions', type: 'udp', value: tunnelUserCount.udp }); } catch (ex) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sent tunnel statistics to the server, only send this if compression was used.
|
// Sent tunnel statistics to the server, only send this if compression was used.
|
||||||
if (this.bytesSent_uncompressed.toString() != this.bytesSent_actual.toString()) {
|
if (this.bytesSent_uncompressed.toString() != this.bytesSent_actual.toString()) {
|
||||||
mesh.SendCommand({
|
mesh.SendCommand({
|
||||||
|
@ -1375,6 +1375,8 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
|||||||
if (command.type == 'kvm') { obj.sessions.kvm = command.value; }
|
if (command.type == 'kvm') { obj.sessions.kvm = command.value; }
|
||||||
else if (command.type == 'terminal') { obj.sessions.terminal = command.value; }
|
else if (command.type == 'terminal') { obj.sessions.terminal = command.value; }
|
||||||
else if (command.type == 'files') { obj.sessions.files = command.value; }
|
else if (command.type == 'files') { obj.sessions.files = command.value; }
|
||||||
|
else if (command.type == 'tcp') { obj.sessions.tcp = command.value; }
|
||||||
|
else if (command.type == 'udp') { obj.sessions.udp = command.value; }
|
||||||
obj.updateSessions();
|
obj.updateSessions();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -494,7 +494,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
|||||||
// Send connection request to agent
|
// Send connection request to agent
|
||||||
const rcookie = parent.parent.encodeCookie({ ruserid: user._id }, parent.parent.loginCookieEncryptionKey);
|
const rcookie = parent.parent.encodeCookie({ ruserid: user._id }, parent.parent.loginCookieEncryptionKey);
|
||||||
if (obj.id == undefined) { obj.id = ('' + Math.random()).substring(2); } // If there is no connection id, generate one.
|
if (obj.id == undefined) { obj.id = ('' + Math.random()).substring(2); } // If there is no connection id, generate one.
|
||||||
const command = { nodeid: cookie.nodeid, action: 'msg', type: 'tunnel', value: '*/meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, tcpport: cookie.tcpport, tcpaddr: cookie.tcpaddr, soptions: {} };
|
const command = { nodeid: cookie.nodeid, action: 'msg', type: 'tunnel', userid: user._id, value: '*/meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, tcpport: cookie.tcpport, tcpaddr: cookie.tcpaddr, soptions: {} };
|
||||||
if (typeof domain.consentmessages == 'object') {
|
if (typeof domain.consentmessages == 'object') {
|
||||||
if (typeof domain.consentmessages.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
|
if (typeof domain.consentmessages.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
|
||||||
if (typeof domain.consentmessages.desktop == 'string') { command.soptions.consentMsgDesktop = domain.consentmessages.desktop; }
|
if (typeof domain.consentmessages.desktop == 'string') { command.soptions.consentMsgDesktop = domain.consentmessages.desktop; }
|
||||||
@ -526,7 +526,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
|||||||
const rcookie = parent.parent.encodeCookie({ ruserid: user._id }, parent.parent.loginCookieEncryptionKey);
|
const rcookie = parent.parent.encodeCookie({ ruserid: user._id }, parent.parent.loginCookieEncryptionKey);
|
||||||
|
|
||||||
if (obj.req.query.tcpport != null) {
|
if (obj.req.query.tcpport != null) {
|
||||||
const command = { nodeid: obj.req.query.nodeid, action: 'msg', type: 'tunnel', value: '*/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: {} };
|
const command = { nodeid: obj.req.query.nodeid, action: 'msg', type: 'tunnel', userid: user._id, value: '*/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: {} };
|
||||||
if (typeof domain.consentmessages == 'object') {
|
if (typeof domain.consentmessages == 'object') {
|
||||||
if (typeof domain.consentmessages.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
|
if (typeof domain.consentmessages.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
|
||||||
if (typeof domain.consentmessages.desktop == 'string') { command.soptions.consentMsgDesktop = domain.consentmessages.desktop; }
|
if (typeof domain.consentmessages.desktop == 'string') { command.soptions.consentMsgDesktop = domain.consentmessages.desktop; }
|
||||||
@ -542,7 +542,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
|
|||||||
parent.parent.debug('relay', 'Relay: Sending agent TCP tunnel command: ' + JSON.stringify(command));
|
parent.parent.debug('relay', 'Relay: Sending agent TCP tunnel command: ' + JSON.stringify(command));
|
||||||
if (obj.sendAgentMessage(command, user._id, domain.id) == false) { delete obj.id; parent.parent.debug('relay', 'Relay: Unable to contact this agent (' + obj.req.clientIp + ')'); }
|
if (obj.sendAgentMessage(command, user._id, domain.id) == false) { delete obj.id; parent.parent.debug('relay', 'Relay: Unable to contact this agent (' + obj.req.clientIp + ')'); }
|
||||||
} else if (obj.req.query.udpport != null) {
|
} else if (obj.req.query.udpport != null) {
|
||||||
const command = { nodeid: obj.req.query.nodeid, action: 'msg', type: 'tunnel', value: '*/meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, udpport: obj.req.query.udpport, udpaddr: ((obj.req.query.udpaddr == null) ? '127.0.0.1' : obj.req.query.udpaddr), soptions: {} };
|
const command = { nodeid: obj.req.query.nodeid, action: 'msg', type: 'tunnel', userid: user._id, value: '*/meshrelay.ashx?id=' + obj.id + '&rauth=' + rcookie, udpport: obj.req.query.udpport, udpaddr: ((obj.req.query.udpaddr == null) ? '127.0.0.1' : obj.req.query.udpaddr), soptions: {} };
|
||||||
if (typeof domain.consentmessages == 'object') {
|
if (typeof domain.consentmessages == 'object') {
|
||||||
if (typeof domain.consentmessages.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
|
if (typeof domain.consentmessages.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
|
||||||
if (typeof domain.consentmessages.desktop == 'string') { command.soptions.consentMsgDesktop = domain.consentmessages.desktop; }
|
if (typeof domain.consentmessages.desktop == 'string') { command.soptions.consentMsgDesktop = domain.consentmessages.desktop; }
|
||||||
|
@ -1219,6 +1219,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
if (typeof domain.notificationmessages.files == 'string') { command.soptions.notifyMsgFiles = domain.notificationmessages.files; }
|
if (typeof domain.notificationmessages.files == 'string') { command.soptions.notifyMsgFiles = domain.notificationmessages.files; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add userid
|
||||||
|
command.userid = user._id;
|
||||||
|
|
||||||
// Add tunnel pre-message deflate
|
// Add tunnel pre-message deflate
|
||||||
if (typeof parent.parent.config.settings.agentwscompression == 'boolean') { command.perMessageDeflate = parent.parent.config.settings.agentwscompression; }
|
if (typeof parent.parent.config.settings.agentwscompression == 'boolean') { command.perMessageDeflate = parent.parent.config.settings.agentwscompression; }
|
||||||
}
|
}
|
||||||
|
12
package.json
12
package.json
@ -2,10 +2,14 @@
|
|||||||
"name": "meshcentral",
|
"name": "meshcentral",
|
||||||
"version": "0.5.94",
|
"version": "0.5.94",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Remote Management",
|
"Remote Device Management",
|
||||||
"Intel AMT",
|
"Remote Device Monitoring",
|
||||||
"Active Management",
|
"Remote Desktop",
|
||||||
"Remote Desktop"
|
"Remote Terminal",
|
||||||
|
"Remote File Access",
|
||||||
|
"KVM",
|
||||||
|
"Intel Active Management Technology",
|
||||||
|
"Intel AMT"
|
||||||
],
|
],
|
||||||
"homepage": "http://meshcommander.com",
|
"homepage": "http://meshcommander.com",
|
||||||
"description": "Web based remote computer management and file server",
|
"description": "Web based remote computer management and file server",
|
||||||
|
@ -3341,7 +3341,7 @@
|
|||||||
var devNotify = '';
|
var devNotify = '';
|
||||||
if (node.sessions != null) {
|
if (node.sessions != null) {
|
||||||
// Sessions are active
|
// Sessions are active
|
||||||
if ((node.sessions.kvm != null) || (node.sessions.terminal != null) || (node.sessions.files != null)) {
|
if ((node.sessions.kvm != null) || (node.sessions.terminal != null) || (node.sessions.files != null) || (node.sessions.tcp != null) || (node.sessions.udp != null)) {
|
||||||
if (view == 2) {
|
if (view == 2) {
|
||||||
devNotify = '<img onclick=showDeviceSessions(\'' + node._id + '\',null,event) class=deviceNotifySmallDot src=images/icon-relay-notify10.png width=10 height=10>';
|
devNotify = '<img onclick=showDeviceSessions(\'' + node._id + '\',null,event) class=deviceNotifySmallDot src=images/icon-relay-notify10.png width=10 height=10>';
|
||||||
} else {
|
} else {
|
||||||
@ -3632,6 +3632,12 @@
|
|||||||
} else if (i == 'files') {
|
} else if (i == 'files') {
|
||||||
x += '<u>' + "Files" + '</u>';
|
x += '<u>' + "Files" + '</u>';
|
||||||
for (var j in node.sessions.files) { x += addHtmlValue4(getUserName(j), ((node.sessions.files[j] == 1)?"1 session":nobreak(format("{0} sessions", node.sessions.files[j])))); }
|
for (var j in node.sessions.files) { x += addHtmlValue4(getUserName(j), ((node.sessions.files[j] == 1)?"1 session":nobreak(format("{0} sessions", node.sessions.files[j])))); }
|
||||||
|
} else if (i == 'tcp') {
|
||||||
|
x += '<u>' + "TCP Routing" + '</u>';
|
||||||
|
for (var j in node.sessions.tcp) { x += addHtmlValue4(getUserName(j), ((node.sessions.tcp[j] == 1)?"1 session":nobreak(format("{0} sessions", node.sessions.tcp[j])))); }
|
||||||
|
} else if (i == 'udp') {
|
||||||
|
x += '<u>' + "UDP Routing" + '</u>';
|
||||||
|
for (var j in node.sessions.udp) { x += addHtmlValue4(getUserName(j), ((node.sessions.udp[j] == 1)?"1 session":nobreak(format("{0} sessions", node.sessions.udp[j])))); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (x != '') setDialogMode(2, "Sessions" + ' - ' + EscapeHtml(node.name), 1, null, x, 'SESSIONS-' + node._id);
|
if (x != '') setDialogMode(2, "Sessions" + ' - ' + EscapeHtml(node.name), 1, null, x, 'SESSIONS-' + node._id);
|
||||||
@ -5262,7 +5268,7 @@
|
|||||||
currentNode = node;
|
currentNode = node;
|
||||||
|
|
||||||
// Device Notification
|
// Device Notification
|
||||||
QV('p10deviceNotify', (currentNode.sessions != null) && ((currentNode.sessions.kvm != null) || (currentNode.sessions.terminal != null) || (currentNode.sessions.files != null)));
|
QV('p10deviceNotify', (currentNode.sessions != null) && ((currentNode.sessions.kvm != null) || (currentNode.sessions.terminal != null) || (currentNode.sessions.files != null) || (currentNode.sessions.tcp != null) || (currentNode.sessions.udp != null)));
|
||||||
|
|
||||||
// Device Battery
|
// Device Battery
|
||||||
QV('p10deviceBattery', false);
|
QV('p10deviceBattery', false);
|
||||||
|
Loading…
Reference in New Issue
Block a user