diff --git a/meshagent.js b/meshagent.js index ba29a92c..68d78790 100644 --- a/meshagent.js +++ b/meshagent.js @@ -1058,7 +1058,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { db.Get('iploc_' + obj.remoteaddr, function (err, iplocs) { if ((iplocs != null) && (iplocs.length == 1)) { // We have a location in the database for this remote IP - const iploc = nodes[0], x = {}; + const iploc = iplocs[0], x = {}; if ((iploc != null) && (iploc.ip != null) && (iploc.loc != null)) { x.publicip = iploc.ip; x.iploc = iploc.loc + ',' + (Math.floor((new Date(iploc.date)) / 1000)); @@ -1067,10 +1067,10 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { } else { // Check if we need to ask for the IP location var doIpLocation = 0; - if (device.iploc == null) { + if (obj.iploc == null) { doIpLocation = 1; } else { - const loc = device.iploc.split(','); + const loc = obj.iploc.split(','); if (loc.length < 3) { doIpLocation = 2; } else { diff --git a/meshcentral-config-schema.json b/meshcentral-config-schema.json index 4e59e088..4ce435ed 100644 --- a/meshcentral-config-schema.json +++ b/meshcentral-config-schema.json @@ -1742,6 +1742,11 @@ "default": false, "description": "Enables the geo-location feature and device location map in the user interface, this feature is not being worked on." }, + "ipLocation": { + "type": "boolean", + "default": false, + "description": "When enabled, the remote agents will submit there approximate location to MeshCentral, Use in combination with \"geoLocation\"." + }, "novnc": { "type": "boolean", "default": true, diff --git a/sample-config-advanced.json b/sample-config-advanced.json index d7242ddc..2fd5360e 100644 --- a/sample-config-advanced.json +++ b/sample-config-advanced.json @@ -316,6 +316,7 @@ "_agentNoProxy": true, "_lockAgentDownload": true, "_geoLocation": true, + "_ipLocation": true, "_novnc": false, "_mstsc": true, "_ssh": true,