Small server written in Go that responds with GeoIP data for given IP in chosen format (xml/json/html)
This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com.
Development environment built using https://github.com/FreakyDazio/vagrant-golang.
- Clone this repository
git clone [email protected]:3fs/geoip-lookup.git
. - Move to geoip-lookup directory
cd geoip-lookup
. - Run
vagrant up
to start development environment. - Run
vagrant provision
to add all dependencies. - Connect to host via
vagrant ssh
. - Move to /vagrant directory via
cd /vagrant
. - Setup and run project with
. build.sh
. - Go to http://192.168.33.10:8080 to see it in action.
- Server can be started anytime by using command
geoip-lookupd
. - Default port number is 8080. However, port number can be set using first argument of command. Example:
geoip-lookupd 3333
.
Any IP can be queried via URL: http://192.168.33.10:8080/{IP}/{format}
.
Response can be returned in HTML, JSON or XML format
- http://192.168.33.10:8080/212.58.246.93
- http://192.168.33.10:8080/212.58.246.93/json
- http://192.168.33.10:8080/212.58.246.93/xml
If IP is not provided in URL, IP from RemoteAddr is used (visitor's IP).