diff --git a/meshagent.js b/meshagent.js index 45565a8c..c571f71d 100644 --- a/meshagent.js +++ b/meshagent.js @@ -87,7 +87,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { } } else { // Update the last connect time - obj.db.Set({ _id: 'lc' + obj.dbNodeKey, type: 'lastconnect', domain: domain.id, time: obj.connectTime }); + if (obj.authenticated == 2) { obj.db.Set({ _id: 'lc' + obj.dbNodeKey, type: 'lastconnect', domain: domain.id, time: obj.connectTime, addr: obj.remoteaddrport }); } } delete obj.nodeid; }; @@ -377,7 +377,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { // Mark when we connected to this agent obj.connectTime = Date.now(); - obj.db.Set({ _id: 'lc' + obj.dbNodeKey, type: 'lastconnect', domain: domain.id, time: obj.connectTime }); + obj.db.Set({ _id: 'lc' + obj.dbNodeKey, type: 'lastconnect', domain: domain.id, time: obj.connectTime, addr: obj.remoteaddrport }); // See if this node exists in the database if (nodes.length == 0) { diff --git a/meshuser.js b/meshuser.js index 754e0657..673fd2fa 100644 --- a/meshuser.js +++ b/meshuser.js @@ -354,7 +354,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use // Query the database for the last time this node connected obj.db.Get('lc' + command.nodeid, function (err, docs) { - if ((docs != null) && (docs.length > 0)) { try { ws.send(JSON.stringify({ action: 'lastconnect', nodeid: command.nodeid, time: docs[0].time })); } catch (ex) { } } + if ((docs != null) && (docs.length > 0)) { try { ws.send(JSON.stringify({ action: 'lastconnect', nodeid: command.nodeid, time: docs[0].time, addr: docs[0].addr })); } catch (ex) { } } }); break; } diff --git a/package.json b/package.json index 59ce817c..75d4fedf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.2.7-f", + "version": "0.2.7-g", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/images/iplocation.png b/public/images/iplocation.png new file mode 100644 index 00000000..dc199e72 Binary files /dev/null and b/public/images/iplocation.png differ diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 581046a1..5b837a6d 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1 +1 @@ - MeshCentral
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file + MeshCentral
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file diff --git a/views/default.handlebars b/views/default.handlebars index 0e912280..9e6f033d 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -1235,6 +1235,7 @@ var node = getNodeFromId(message.nodeid); if (node != null) { node.lastconnect = message.time; + node.lastaddr = message.addr; if ((currentNode._id == node._id) && (Q('MainComputerState').innerHTML == '')) { QH('MainComputerState', 'Last seen:
' + new Date(node.lastconnect).toLocaleDateString() + ', ' + new Date(node.lastconnect).toLocaleTimeString() + '
'); } @@ -1275,8 +1276,19 @@ QH('d2netinfo', 'No network interface information available for this device.'); } else { var x = '
'; - x += addHtmlValue2('Last Updated', new Date(message.updateTime).toLocaleString()); - if (currentNode.publicip) { x += addHtmlValue2('Public IP address', currentNode.publicip); } + if (currentNode.publicip) { + x += addHtmlValue2('Public IP address', currentNode.publicip); + } else { + if (currentNode.lastconnect) { x += addHtmlValue2('Last agent connection', new Date(currentNode.lastconnect).toLocaleString()); } + if (currentNode.lastaddr) { + if (isPrivateIP(currentNode.lastaddr)) { + x += addHtmlValue2('Last agent address:port', currentNode.lastaddr); + } else { + x += addHtmlValue2('Last agent address:port', '' + currentNode.lastaddr + ''); + } + } + } + x += addHtmlValue2('Last interfaces update', new Date(message.updateTime).toLocaleString()); for (var i in message.netif) { var net = message.netif[i]; x += '
' @@ -6683,6 +6695,7 @@ function parseUriArgs() { var name, r = {}, parsedUri = window.document.location.href.split(/[\?&|\=]/); parsedUri.splice(0, 1); for (x in parsedUri) { switch (x % 2) { case 0: { name = decodeURIComponent(parsedUri[x]); break; } case 1: { r[name] = decodeURIComponent(parsedUri[x]); var x = parseInt(r[name]); if (x == r[name]) { r[name] = x; } break; } default: { break; } } } return r; } function focusTextBox(x) { setTimeout(function(){ Q(x).selectionStart = Q(x).selectionEnd = 65535; Q(x).focus(); }, 0); } function validateEmail(v) { var emailReg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return emailReg.test(v); } // New version + function isPrivateIP(a) { return (a.startsWith('10.') || a.startsWith('172.16.') || a.startsWith('192.168.')); }