diff --git a/agents/meshcore.js b/agents/meshcore.js
index dfd0f825..222f95fd 100644
--- a/agents/meshcore.js
+++ b/agents/meshcore.js
@@ -341,7 +341,7 @@ function createMeshCore(agent) {
var nextTunnelIndex = 1;
var amtPolicy = 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
function MeshServerLog(msg, state) {
@@ -1127,7 +1127,6 @@ function createMeshCore(agent) {
});
}
-
//sendConsoleText('onTunnelUpgrade - ' + this.tcpport + ' - ' + this.udpport);
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'; }
s.tcprelay = net.createConnection(connectionOptions, onTcpRelayTargetTunnelConnect);
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) {
// This is a UDP relay connection, get the UDP socket setup. // TODO: ***************
s.data = onUdpRelayServerTunnelData;
@@ -1148,6 +1153,12 @@ function createMeshCore(agent) {
s.udprelay.udpport = this.udpport;
s.udprelay.udpaddr = this.udpaddr;
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 {
// This is a normal connect for KVM/Terminal/Files
s.data = onTunnelData;
@@ -1189,6 +1200,17 @@ function createMeshCore(agent) {
var tunnel = tunnels[this.httprequest.index];
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.
if (this.bytesSent_uncompressed.toString() != this.bytesSent_actual.toString()) {
mesh.SendCommand({
diff --git a/meshagent.js b/meshagent.js
index 83758490..24b182fe 100644
--- a/meshagent.js
+++ b/meshagent.js
@@ -1375,6 +1375,8 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
if (command.type == 'kvm') { obj.sessions.kvm = 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 == 'tcp') { obj.sessions.tcp = command.value; }
+ else if (command.type == 'udp') { obj.sessions.udp = command.value; }
obj.updateSessions();
break;
}
diff --git a/meshrelay.js b/meshrelay.js
index 75973466..7acab67e 100644
--- a/meshrelay.js
+++ b/meshrelay.js
@@ -494,7 +494,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
// Send connection request to agent
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.
- 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.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
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);
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.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
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));
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) {
- 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.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
if (typeof domain.consentmessages.desktop == 'string') { command.soptions.consentMsgDesktop = domain.consentmessages.desktop; }
diff --git a/meshuser.js b/meshuser.js
index 27beca3f..ace06a63 100644
--- a/meshuser.js
+++ b/meshuser.js
@@ -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; }
}
+ // Add userid
+ command.userid = user._id;
+
// Add tunnel pre-message deflate
if (typeof parent.parent.config.settings.agentwscompression == 'boolean') { command.perMessageDeflate = parent.parent.config.settings.agentwscompression; }
}
diff --git a/package.json b/package.json
index 1728e322..24391b90 100644
--- a/package.json
+++ b/package.json
@@ -2,10 +2,14 @@
"name": "meshcentral",
"version": "0.5.94",
"keywords": [
- "Remote Management",
- "Intel AMT",
- "Active Management",
- "Remote Desktop"
+ "Remote Device Management",
+ "Remote Device Monitoring",
+ "Remote Desktop",
+ "Remote Terminal",
+ "Remote File Access",
+ "KVM",
+ "Intel Active Management Technology",
+ "Intel AMT"
],
"homepage": "http://meshcommander.com",
"description": "Web based remote computer management and file server",
diff --git a/views/default.handlebars b/views/default.handlebars
index e1c268a9..54514af7 100644
--- a/views/default.handlebars
+++ b/views/default.handlebars
@@ -3341,7 +3341,7 @@
var devNotify = '';
if (node.sessions != null) {
// 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) {
devNotify = '';
} else {
@@ -3632,6 +3632,12 @@
} else if (i == 'files') {
x += '' + "Files" + '';
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 += '' + "TCP Routing" + '';
+ 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 += '' + "UDP Routing" + '';
+ 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);
@@ -5262,7 +5268,7 @@
currentNode = node;
// 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
QV('p10deviceBattery', false);