Skip to content

dharmendrakariya/geoip-rs

 
 

Repository files navigation

geoip-rs with self update

Fork of geoip-rs with self-update mechanism, and updated dependencies.

geoip-rs is a geoip service: it provides geographical information about the calling or the specified IP address. It supports both IPV4 and IPV6.

Example response

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"
}

Speed

On an 8 cores Intel i7, geoip.rs can serve ~30K requests/sec.

Dataset

geoip-rs uses the free dataset provided by maxmind. It's not bundled: you have to download it separately.

Download "GeoLite2 City" dataset in binary format from here and unzip it.

Running

Install geoip.rs with

cargo install geoip-rs

If you don't have cargo, install it with

curl https://sh.rustup.rs -sSf | sh

or read the tutorial for additional instructions.

You can specify the dataset location on the command line

geoip-rs /path/to/GeoLite2-City.mmdb
# or you can omit it and it will download current db given your license.

or via environment variable

export GEOIP_RS_DB_PATH=/path/to/GeoLite2-City.mmdb
export GEOIP_LICENSE=xxxxxxxxxx
geoip-rs

or via .env

cp .env.template .env
#edit .env appropriately
geoip-rs

You can also customize the host and port geoip.rs will listen to

export GEOIP_RS_DB_PATH=/path/to/GeoLite2-City.mmdb
export GEOIP_RS_HOST=192.168.0.1
export GEOIP_RS_PORT=8080
export GEOIP_LICENSE=xxxxxxxxxx

geoip-rs

or you can copy .env.template to .env and customize its contents

Kubernetes support

You can deploy geoip service on k8s as well.

You can find the k8s manifest under k8s folder.

Just make sure you have X-forwarded-for enabled on your ingress-nginx

License

This project is licensed under the Apache License, Version 2.0

About

geoip service written in rust https://geoip.rs/

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 96.0%
  • Dockerfile 4.0%