Skip to content

A Go (golang) HTTP service which will tell you the country associated with a given IP.

License

Notifications You must be signed in to change notification settings

dseevr/go-geoip-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status goreportcard

Go GeoIP Service

A Go (golang) HTTP service which will tell you the country associated with a given IP.

Usage

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

Looking up an IP

curl -w "\n" "http://localhost:12345/lookup?ip=1.2.3.4"

Response:

{"country":"AU"}

Prerequisites

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/

Running the tests

You will need to have a MaxMind database in the base folder called test.db.

Then just run make test!

License

BSD

About

A Go (golang) HTTP service which will tell you the country associated with a given IP.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published