Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

twisted1919/geoip-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geoip-go

A simple GeoIP server written in GO language based on https://github.com/oschwald/geoip2-golang

Install

# clone this repository locally (or download it) :  
$ mkdir geoip-go && cd geoip-go && git clone https://github.com/twisted1919/geoip-go.git .  

# install go dependencies:  
$ go get github.com/julienschmidt/httprouter  
$ go get github.com/oschwald/geoip2-golang

# fetch latest geoip2 database:  
$ wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz  

# extract the database  
$ gunzip GeoLite2-City.mmdb.gz  

# build the binary:  
$ go build -o geoip-go  

# if needed, edit config.json accordingly

Usage

Start the server with proper flags, use -help to see available options:

# start server
$ ./geoip-go -database.file="GeoLite2-City.mmdb"
# client response after sending a GET request to https://localhost:8000/check/123.123.123.123
{
  "status": "success",
  "message": "OK [took 41.622µs]",
  "data": {
    "continent": "Asia",
    "country_name": "China",
    "country_code": "CN",
    "state_name": "Beijing Shi",
    "city_name": "Beijing",
    "postal_code": "",
    "latitude": 39.9289,
    "longitude": 116.3883,
    "timezone": "Asia/Shanghai"
  }
}

Notes

  • command line flags take priority over the ones from configuration file
  • make sure you use -server.password flag to set a password if the server listens on a public interface

Enjoy.

About

GeoIP Server written in GO language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages