geoip

package module
v0.0.0-...-8f8d974 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

README

geoip2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Languages = []string{"de", "en", "es", "fr", "ja", "pt-BR", "ru", "zh-CN"}

Functions

func IP2Int

func IP2Int(ip net.IP) uint32

func IPRange

func IPRange(cidr string) (start int, end int, err error)

Types

type ASNBlock

type ASNBlock struct {
	Network string `json:"network"`
	Organization
}

type CityBlock

type CityBlock struct {
	ID                          int64   `json:"id"`
	Network                     string  `json:"network"`
	GeonameID                   int64   `json:"geoname_id"`
	RegisteredCountryGeonameID  string  `json:"registered_country_geoname_id"`
	RepresentedCountryGeonameID string  `json:"represented_country_geoname_id"`
	IsAnonymousProxy            int     `json:"is_anonymous_proxy"`
	IsSatelliteProvider         int     `json:"is_satellite_provider"`
	PostalCode                  string  `json:"postal_code"`
	Latitude                    float64 `json:"latitude"`
	Longitude                   float64 `json:"longitude"`
	AccuracyRadius              int     `json:"accuracy_radius"`
	// contains filtered or unexported fields
}

type CityLocation

type CityLocation struct {
	ID                  int64  `json:"id"`
	GeonameID           int64  `json:"geoname_id"`
	LocaleCode          string `json:"locale_code"`
	ContinentCode       string `json:"continent_code"`
	ContinentName       string `json:"continent_name"`
	CountryISOCode      string `json:"country_iso_code"`
	CountryName         string `json:"country_name"`
	Subdivision1ISOCode string `json:"subdivision_1_iso_code"`
	Subdivision1Name    string `json:"subdivision_1_name"`
	Subdivision2ISOCode string `json:"subdivision_2_iso_code"`
	Subdivision2Name    string `json:"subdivision_2_name"`
	CityName            string `json:"city_name"`
	MetroCode           string `json:"metro_code"`
	TimeZone            string `json:"time_zone"`
	IsInEuropeanUnion   string `json:"is_in_european_union"`
}

type CountryBlock

type CountryBlock struct {
	ID                          int64  `json:"id"`
	Network                     string `json:"network"`
	GeonameID                   int64  `json:"geoname_id"`
	RegisteredCountryGeonameID  string `json:"registered_country_geoname_id"`
	RepresentedCountryGeonameID string `json:"represented_country_geoname_id"`
	IsAnonymousProxy            string `json:"is_anonymous_proxy"`
	IsSatelliteProvider         string `json:"is_satellite_provider"`
	// contains filtered or unexported fields
}

type CountryLocation

type CountryLocation struct {
	ID                int64  `json:"id"`
	GeonameID         int64  `json:"geoname_id"`
	LocaleCode        string `json:"locale_code"`
	ContinentCode     string `json:"continent_code"`
	ContinentName     string `json:"continent_name"`
	CountryISOCode    string `json:"country_iso_code"`
	CountryName       string `json:"country_name"`
	IsInEuropeanUnion string `json:"is_in_european_union"`
}

type GeoLite2Loader

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

func NewGeoLite2Loader

func NewGeoLite2Loader(db *sql.DB) *GeoLite2Loader

func (*GeoLite2Loader) Local

func (loader *GeoLite2Loader) Local(asnPath, cityPath, countryPath string) error

func (*GeoLite2Loader) Remote

func (loader *GeoLite2Loader) Remote(asnEditionID, cityEditionID, countryEditionID string) error

func (*GeoLite2Loader) Update

func (loader *GeoLite2Loader) Update() error

type Geoip2

type Geoip2 interface {
	//AsnBlock 查询IP ASN信息,返回 ASNBlock
	AsnBlock(ip net.IP) (*ASNBlock, error)
	//BlocksByAsnNumber 查询某组织拥有的 ASNBlock,返回 ASNBlock 数组
	BlocksByAsnNumber(int64) ([]ASNBlock, error)
	//BlocksByAsnName 查询某组织拥有的 ASNBlock,返回 ASNBlock 数组
	BlocksByAsnName(string) ([]ASNBlock, error)
	//Organizations 查询全部ASN组织,返回 Organization 数组
	Organizations() ([]Organization, error)

	//CityBlock 查询IP信息,返回 CityBlocks
	CityBlock(net.IP) (*CityBlock, error)
	//BlocksByCityCode 查询城市级某地域IP地址段,返回 CityBlock 数组
	BlocksByCityCode(language, countryCode, cityCode string) ([]CityBlock, error)

	//CountryBlock 查询IP信息,返回 CountryBlock
	CountryBlock(net.IP) (*CountryBlock, error)
	//BlocksByCountryCode 查询国家级某地域IP地址段,返回 CountryBlock 数组
	BlocksByCountryCode(string, string) ([]CountryBlock, error)
	//BlocksByContinentCode 查询洲级某地域IP地址段,返回 CountryBlock 数组
	BlocksByContinentCode(string, string) ([]CountryBlock, error)
}

func NewGeolite2

func NewGeolite2(db *sql.DB) Geoip2

type GeoipSql

type GeoipSql struct {
	CreateTable string
	Insert      string
}

type Geolite2

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

func (Geolite2) AsnBlock

func (geo Geolite2) AsnBlock(ip net.IP) (*ASNBlock, error)

func (Geolite2) BlocksByAsnName

func (geo Geolite2) BlocksByAsnName(name string) ([]ASNBlock, error)

func (Geolite2) BlocksByAsnNumber

func (geo Geolite2) BlocksByAsnNumber(number int64) ([]ASNBlock, error)

func (Geolite2) BlocksByCityCode

func (geo Geolite2) BlocksByCityCode(language, countryCode, cityCode string) ([]CityBlock, error)

func (Geolite2) BlocksByContinentCode

func (geo Geolite2) BlocksByContinentCode(language, code string) ([]CountryBlock, error)

func (Geolite2) BlocksByCountryCode

func (geo Geolite2) BlocksByCountryCode(language, code string) ([]CountryBlock, error)

func (Geolite2) CityBlock

func (geo Geolite2) CityBlock(ip net.IP) (*CityBlock, error)

func (Geolite2) CountryBlock

func (geo Geolite2) CountryBlock(ip net.IP) (*CountryBlock, error)

func (Geolite2) Organizations

func (geo Geolite2) Organizations() ([]Organization, error)

type Organization

type Organization struct {
	AutonomousSystemNumber       int    `json:"autonomous_system_number"`
	AutonomousSystemOrganization string `json:"autonomous_system_organization"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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