A Go (golang) HTTP service which will tell you the country associated with a given IP.
Go get:
go get github.com/dseevr/go-geoip-service
$GOPATH/bin/go-geoip-service --db-path=/mm.db --port=1234
Build it yourself:
git clone [email protected]:dseevr/go-geoip-service.git
cd go-geoip-service
make
./go-geoip-service --db-path=/mm.db --port=1234
Run from Docker:
docker run --rm -it \
-p 1234:1234 \
-v /foo/bar/GeoLite2-Country.mmdb:/mm.db:ro \
billrobinson/go-geoip-service --db-path=/mm.db --port=1234
curl -w "\n" "http://localhost:12345/lookup?ip=1.2.3.4"
Response:
{"country":"AU"}
You will need a GeoLite2 database from MaxMind. Specify it with the --db-path
option.
You can get a database here: https://dev.maxmind.com/geoip/geoip2/geolite2/
You will need to have a MaxMind database in the base folder called test.db
.
Then just run make test
!
BSD