Skip to content

An extensible GeoIP service that can be a REST API or command line tool

License

Notifications You must be signed in to change notification settings

wisepythagoras/geoip-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GeoIP Service

A GeoIP service that can be a REST API or command line tool.

Building

This app has as few dependencies as possible. Notably Gin, for setting up a webserver, and govalidator, for validating input. You should be able to get started by running the following:

go build .

Note that you will need to get your own copy of the Maxmind IP database (see info here).

Using

Usage of ./geoip-service:
  -dns-servers string
        The list of DNS servers. If not specified defaults to Cloudflare, Google, and OpenDNS
  -domain string
        A domain name
  -ext-dir string
        Specify the location of the folder containing the extensions
  -ip string
        An IP address
  -pub-dir string
        Specify the location of the public folder (to serve a front end)
  -serve
        Run the HTTP server
  -sip string
        The IP to serve on (127.0.0.1 will make it accessible only from localhost) (default "127.0.0.1")
  -whitelist string
        If specified, it will only allow (only used with -serve)
# To query right from the command line.
./geoip-service -domain one.one.one.one
./geoip-service -ip 1.1.1.1

# To run the HTTP API.
./geoip-service -serve

# To serve on a specific iface.
./geoip-service -serve -sip 0.0.0.0

# You can also add a whitelist of IPs to allow to access the API and a custom list of
# DNS servers to query.
./geoip-service -serve -whitelist ./whitelist -sip 0.0.0.0 -dns-servers ./dns_servers

The -pub-dir flag can be used to specify a front end application that calls all the APIs. There's an example of this in the geoip-service-fe repository.

Extensions

The app has an integrated extension engine which is mostly meant to be used when running it as an API server. An extension can register API endpoints, run cron jobs, and manage data on their own, which the main app can query. Below you'll find an example of an extension that queries data from a 3rd party IP list.

See the full documentation on extensions here.

License

Although the source code is licensed under GNU GPLv3, I prohibit the use of this code for the purpsoses of training any kind of AI model. This applies to any version of the source code and/or commit, historic, current, and/or new.