ipinfo

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2018 License: MIT Imports: 10 Imported by: 0

README

Kyber IPLocator

Build

    cd cmd
    go build - v .

Run

    cd cmd
    ./cmd --data-dir=.
Available flags

data-dir: where to load/store db file

Available API

Get user info by address
GET http://localhost:8001/ip/:ip

response: Return country code

Sample response:

{
    "country": "US"
}

Documentation

Index

Constants

View Source
const ErrInvalidIP = "Invalid ip input"

ErrInvalidIP error for invalid ip input

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

HTTPServer to serve endpoint

func NewHTTPServer

func NewHTTPServer(sugar *zap.SugaredLogger, dataDir string, host string) (*HTTPServer, error)

NewHTTPServer return an instance of HTTPServer

func (*HTTPServer) Run

func (h *HTTPServer) Run() error

Run start HTTPServer

type Locator

type Locator struct {
	// contains filtered or unexported fields
}

Locator is a resolver that query data of IP from MaxMind's GeoLite2 database.

func NewLocator

func NewLocator(sugar *zap.SugaredLogger, dataDir string) (*Locator, error)

NewLocator returns an instance of ipLocator.

func (*Locator) IPToCountry

func (il *Locator) IPToCountry(ipParsed net.IP) (string, error)

IPToCountry returns the country of given IP address.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL