geo

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2019 License: MIT Imports: 2 Imported by: 0

README

geo-cli

Geo cli tool written in Golang using MaxMind geo data

GoDoc Go Report Card

Installation

$ go install github.com/major1201/geo-cli/cmd/geo

Usage

Download a MaxMind geo data file in https://dev.maxmind.com/geoip/geoip2/geolite2/

Set the environment var

export GEO_MMDBFILE=/opt/GeoLite2-City.mmdb

Query one address in detail

geo --detail 81.2.69.142

Query multiple addresses in one-line format

geo www.google.com 81.2.69.142

Read from pipe

traceroute www.google.com | geo

Specify language

geo --language zh-CN 81.2.69.142

Contributing

Just fork the repositry and open a pull request with your changes.

Licence

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(file string) (*geoip2.Reader, error)

Open an mmdb file by MaxMind

Types

type Geo

type Geo struct {
	ContinentCode      string  `` /* 189-byte string literal not displayed */
	ContinentName      string  `` /* 188-byte string literal not displayed */
	CountryIsoCode     string  `` /* 196-byte string literal not displayed */
	CountryName        string  `` /* 147-byte string literal not displayed */
	SubdivisionIsoCode string  `` /* 214-byte string literal not displayed */
	SubdivisionName    string  `` /* 182-byte string literal not displayed */
	CityName           string  `` /* 163-byte string literal not displayed */
	PostalCode         string  `` /* 168-byte string literal not displayed */
	Latitude           float64 `de:"Breite" en:"Latitude" es:"Latitud" fr:"Latitude" ja:"緯度" pt-BR:"Latitude" ru:"широта" zh-CN:"纬度"`
	Longitude          float64 `de:"Länge" en:"Longitude" es:"Longitud" fr:"Longitude" ja:"経度" pt-BR:"Longitude" ru:"долгота" zh-CN:"经度"`
	TimeZone           string  `` /* 151-byte string literal not displayed */
}

Geo is the parsed record geo data

type RetData

type RetData struct {
	Host    string
	IP      net.IP
	Error   bool
	Message string
	Geo     *Geo
}

RetData is the struct to be returned by Query

func Query

func Query(host string, db *geoip2.Reader, language string) []*RetData

Query a host for record data

Directories

Path Synopsis
cmd
geo

Jump to

Keyboard shortcuts

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