From 44caca42b10bb4789578c77e6c3971dacacfc43f Mon Sep 17 00:00:00 2001 From: Joe Uhren Date: Sat, 30 Apr 2022 21:27:12 -0600 Subject: [PATCH] Geolocation update for peer sync -freegeoip.app now requires an api key so the peer sync has been updated to use reallyfreegeoip.org instead -Added extra error checking to the peer sync so that it will error out when the geolocation service does not return a proper object --- lib/explorer.js | 2 +- scripts/sync.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/explorer.js b/lib/explorer.js index fbec3a0..35e48dd 100644 --- a/lib/explorer.js +++ b/lib/explorer.js @@ -975,7 +975,7 @@ module.exports = { }, get_geo_location: function(address, cb) { - request({uri: 'https://freegeoip.app/json/' + address, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, geo) { + request({uri: 'https://reallyfreegeoip.org/json/' + address, json: true, headers: {'User-Agent': 'eiquidus'}}, function (error, response, geo) { return cb(error, geo); }); }, diff --git a/scripts/sync.js b/scripts/sync.js index 5f0acb3..f1fbca4 100644 --- a/scripts/sync.js +++ b/scripts/sync.js @@ -458,6 +458,9 @@ if (lib.is_locked([database]) == false) { if (error) { console.log(error); exit(1); + } else if (geo == null || typeof geo != 'object') { + console.log('Error: geolocation api did not return a valid object'); + exit(1); } else { // add peer to collection db.create_peer({