Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch validator geo & host data using reverse IP lookups #7

Open
jamiew opened this issue Jul 21, 2021 · 5 comments
Open

Fetch validator geo & host data using reverse IP lookups #7

jamiew opened this issue Jul 21, 2021 · 5 comments

Comments

@jamiew
Copy link
Contributor

jamiew commented Jul 21, 2021

Explorer API is using KeyCDN to fetch geo location, ISP and other information for each validator

This appears to be publicly accessible and would useful to have in DeWi ETL as well:

ip="34.92.38.196"
curl -s "https://tools.keycdn.com/geo.json?host=$ip" -H "User-Agent: keycdn-tools:https://tools.keycdn.com"

=>

{
  "status": "success",
  "description": "Data successfully received.",
  "data": {
    "geo": {
      "host": "34.92.38.196",
      "ip": "34.92.38.196",
      "rdns": "196.38.92.34.bc.googleusercontent.com",
      "asn": 15169,
      "isp": "GOOGLE",
      "country_name": "Hong Kong",
      "country_code": "HK",
      "region_name": "Central and Western District",
      "region_code": "HCW",
      "city": "Central",
      "postal_code": null,
      "continent_name": "Asia",
      "continent_code": "AS",
      "latitude": 22.2908,
      "longitude": 114.1501,
      "metro_code": null,
      "timezone": "Asia/Hong_Kong",
      "datetime": "2021-07-21 21:00:39"
    }
  }
}

We should investigate if a commercial license is strictly required, or if this is OK for the ~2000 queries or so we would need for initial import

@jamiew jamiew changed the title Import reverse-IP lookup data from KeyCDN Import reverse-IP lookup data for validators Jul 21, 2021
@jamiew jamiew changed the title Import reverse-IP lookup data for validators Reverse-IP lookup data for validators Jul 21, 2021
@jamiew jamiew removed the enhancement label Aug 8, 2021
@jamiew jamiew changed the title Reverse-IP lookup data for validators Fetch validator geo & host data using reverse IP lookups Aug 8, 2021
@dansku
Copy link
Collaborator

dansku commented Aug 9, 2021

This was implemented in the go-shenanigans https://github.com/dewi-alliance/go-etl-shenanigans/blob/main/scheduler/validator_isp.go

@jamiew
Copy link
Contributor Author

jamiew commented Aug 10, 2021

Amazing, love it

Table name is validator_isp

Here's the create statement I dug up from postgres... I think we will need geo_data to be a jsonb

CREATE TABLE public.validator_isp (
    address text NOT NULL,
    isp text,
    geo_data text
);

ALTER TABLE ONLY public.validator_isp
    ADD CONSTRAINT validator_isp_pkey PRIMARY KEY (address);

@jamiew
Copy link
Contributor Author

jamiew commented Aug 10, 2021

Would it be annoying to parse the JSON and include each column individually? It's possible to join on jsonb fields with raw SQL but not via Metabase's nice GUI tools, so I'd likely end up creating a view that does the extraction if we don't do it here

{
  "host": "100.121.169.153",
  "ip": "100.121.169.153",
  "rdns": "100.121.169.153",
  "asn": 0,
  "isp": "",
  "country_name": "",
  "country_code": "",
  "region_name": "",
  "region_code": "",
  "city": "",
  "postal_code": "",
  "continent_name": "",
  "continent_code": "",
  "latitude": 0,
  "longitude": 0,
  "metro_code": 0,
  "timezone": "",
  "datetime": ""
}```

@dansku
Copy link
Collaborator

dansku commented Aug 10, 2021

Added all the fields to its own columns.

@dansku
Copy link
Collaborator

dansku commented Sep 17, 2021

@jamiew this is also done afaik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants