Convert an IPv4 address to a country code
Go to file
Charlotte Som 300b827915 Hook up the range data to the API 2021-12-30 18:10:50 +00:00
data Parse ip2asn data 2021-12-30 18:01:06 +00:00
src Hook up the range data to the API 2021-12-30 18:10:50 +00:00
.editorconfig Parse ip2asn data 2021-12-30 18:01:06 +00:00
.gitignore Initial commit: Cargo template 2021-12-30 17:24:12 +00:00
Cargo.lock Hook up the range data to the API 2021-12-30 18:10:50 +00:00
Cargo.toml Hook up the range data to the API 2021-12-30 18:10:50 +00:00
README.md Parse ip2asn data 2021-12-30 18:01:06 +00:00

README.md

geoip-api

HTTP API for converting an IPv4 address to a country code.

Uses the iptoasn.com dataset.

Setup

Grab the latest ip2asn-v4.tsv.gz and extract it to data/ip2asn-v4.tsv.

Then just use cargo as usual.

Usage

$ http GET 'http://127.0.0.1:8000/192.168.0.1'
{
  "asn": 0,
  "country_code": "None",
  "asn_desc": "Not routed"
}