iquidus / explorer

An open source block explorer
BSD 3-Clause "New" or "Revised" License
747 stars 1.33k forks source link

geoip api #489

Closed ocvcoin closed 2 years ago

ocvcoin commented 2 years ago

TypeError: Cannot read property 'country_name' of undefined at Request._callback (/home/explorer/scripts/peers.js:54:30)

looks like freegeoip.app is down.

ocvcoin commented 2 years ago

I found an alternative free service. https://reallyfreegeoip.org/json/8.8.8.8

more secure:

request({uri: 'https://reallyfreegeoip.org/json/' + address, json: true}, function (error, response, geo) {

                if(
                    typeof geo !== "undefined"  &&
                    typeof geo.country_name !== "undefined" &&
                    typeof geo.country_code !== "undefined"
                )               

              db.create_peer({
                address: address,
                port: port,
                protocol: body[i].version,
                version: body[i].subver.replace('/', '').replace('/', ''),
                country: geo.country_name.replace(/[^a-z0-9]/gi, '-'),
                country_code: geo.country_code.replace(/[^a-z0-9]/gi, '-')
              }, function(){
                loop.next();
              });

            });
joeuhren commented 2 years ago

Great minds think alike! I used the exact same service in my teams explorer which I would highly recommend over this one since the original iquidus hasn't received any updates in over a year and looks to be dead and full of unfixed bugs and security holes.

uaktags commented 2 years ago

Can one of you guys make a pullrequest? Looks like freegeoip changed to ipbase, and their free plan is a very mediocre offering, though it may be good to offload the ip aspect to a module and give people the ability to choose a geoip service/apikey.

joeuhren commented 2 years ago

@uaktags reallyfreegeoip.org is a drop-in replacement for freegeoip.app so only the url needs to change and node syncing works again: https://github.com/iquidus/explorer/pull/492

uaktags commented 2 years ago

Looks good, i merged #492 . Thanks!