GithubHelp home page GithubHelp logo

-m13lwz---geoip-go's Introduction

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 http://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 http://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.

-m13lwz---geoip-go's People

Contributors

twisted1919 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.