blockchain-http icon indicating copy to clipboard operation
blockchain-http copied to clipboard

Add validator IP geolocation

Open allenan opened this issue 4 years ago • 0 comments

we currently augment validators with this data in our apps, but this seems universally useful.

We use the free service from keycdn.com. For example this is what the explorer does. Note the user agent would be different.

const fetchGeo = (ipAddress) => async () => {
  const response = await fetch(
    `https://tools.keycdn.com/geo.json?host=${ipAddress}`,
    {
      headers: { 'User-Agent': 'keycdn-tools:https://explorer.helium.com' },
    },
  )
  const {  data: { geo } } = await response.json()
  return geo
}

allenan avatar Aug 11 '21 23:08 allenan