Added mesh agent IP address geo-location.

This commit is contained in:
Ylian Saint-Hilaire 2019-01-31 15:00:51 -08:00
parent 1bbb37b1ea
commit e6ebca7820
6 changed files with 20 additions and 7 deletions

View File

@ -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) {

View File

@ -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;
}

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.2.7-f",
"version": "0.2.7-g",
"keywords": [
"Remote Management",
"Intel AMT",

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

File diff suppressed because one or more lines are too long

View File

@ -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', '<span style=font-size:12px>Last seen:<br />' + new Date(node.lastconnect).toLocaleDateString() + ', ' + new Date(node.lastconnect).toLocaleTimeString() + '</span>');
}
@ -1275,8 +1276,19 @@
QH('d2netinfo', 'No network interface information available for this device.');
} else {
var x = '<div style=width:100%;max-height:260px;overflow-x:hidden;overflow-y:auto;line-height:160%>';
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', '<a href="https://iplocation.com/?ip=' + currentNode.lastaddr.split(':')[0] + '" rel="noreferrer noopener" target=_blank>' + currentNode.lastaddr + '</a>');
}
}
}
x += addHtmlValue2('Last interfaces update', new Date(message.updateTime).toLocaleString());
for (var i in message.netif) {
var net = message.netif[i];
x += '<hr />'
@ -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.')); }
</script>
</body>
</html>