- Notifications
You must be signed in to change notification settings - Fork12
geoip service written in rusthttps://geoip.rs/
License
ffissore/geoip-rs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
geoip-rs is a geoip service: it provides geographical information about the calling or the specified IP address. It supports both IPV4 and IPV6.
When called with no query params, it resolves the calling IP address. For example:https://api.geoip.rs
When called with the
ip
query param, it resolves the specified IP address. For example:https://api.geoip.rs/?ip=216.58.205.132If the provided IP address is invalid, it falls back to the calling IP address.
When called with the
callback
query param, it returns a JSONP response, with the json wrapped by the specified callback. For example:https://api.geoip.rs/?ip=216.58.205.132&callback=my_functionBy default, responses will be in english. An optional
lang
query param can be provided: if a translation is available, returned data will be in that language. Current list includes:de
,en
,es
,fr
,ja
,pt-BR
,ru
,zh-CH
. For example:https://api.geoip.rs/?ip=216.58.205.132&lang=ja
Valid ip address:
{"ip_address":"46.51.179.90","latitude":53.3331,"longitude":-6.2489,"postal_code":"D02","continent_code":"EU","continent_name":"Europe","country_code":"IE","country_name":"Ireland","region_code":"L","region_name":"Leinster","province_code":"","province_name":"","city_name":"Dublin","timezone":"Europe/Dublin"}
Not found (private) ip address:
{"ip_address":"127.0.0.1"}
On an 8 cores Intel i7, geoip.rs can serve ~30K requests/sec.
geoip-rs uses the free dataset provided bymaxmind. It's not bundled: you have to download it separately.
Download "GeoLite2 City" dataset in binary format fromhere and unzip it.
Install geoip.rs with
cargo install geoip-rs
If you don't havecargo
, install it with
curl https://sh.rustup.rs -sSf| sh
orread the tutorial for additional instructions.
You can specify the dataset location on the command line
geoip-rs /path/to/GeoLite2-City.mmdb
or via environment variable
export GEOIP_RS_DB_PATH=/path/to/GeoLite2-City.mmdbgeoip-rs
or via.env
cp .env.template .env#edit .env appropriatelygeoip-rs
You can also customize the host and port geoip.rs will listen to
export GEOIP_RS_DB_PATH=/path/to/GeoLite2-City.mmdbexport GEOIP_RS_HOST=192.168.0.1export GEOIP_RS_PORT=8080geoip-rs
or you can copy.env.template
to.env
and customize its contents
This project is licensed under the Apache License, Version 2.0
About
geoip service written in rusthttps://geoip.rs/
Topics
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.