geoip

package
v1.0.182 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGeoLite2AsnDownloadUrl

func GetGeoLite2AsnDownloadUrl(licenseKey string) string

func GetGeoLite2CityDownloadUrl

func GetGeoLite2CityDownloadUrl(licenseKey string) string

func GetGeoLite2CountryDownloadUrl

func GetGeoLite2CountryDownloadUrl(licenseKey string) string

func OnlineDownload

func OnlineDownload(downloadUrl string, downloadName string)

Types

type Client

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

func New

func New(asnFilepath string, cityFilepath string, countryFilepath string) (*Client, error)

func NewBuff added in v1.0.161

func NewBuff(asnFile []byte, cityFile []byte, countryFile []byte) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) QueryCity

func (c *Client) QueryCity(ipAddress net.IP) (result QueryCityResult, err error)

func (*Client) QueryCityIP added in v1.0.161

func (c *Client) QueryCityIP(ipAddressStr string) (result QueryCityResult, err error)

QueryCityIP ip地址查询对应归属地信息

type QueryCityResult

type QueryCityResult struct {
	Ip        string `json:"ip,omitempty"` // ip
	Continent struct {
		Code string `json:"code,omitempty"` // 大陆代码
		Name string `json:"name,omitempty"` // 大陆名称
	} `json:"continent,omitempty"`
	Country struct {
		Code string `json:"code,omitempty"` // 国家代码
		Name string `json:"name,omitempty"` // 国家名称
	} `json:"country,omitempty"`
	Province struct {
		Code string `json:"code,omitempty"` // 省份代码
		Name string `json:"name,omitempty"` // 省份名称
	} `json:"province,omitempty"`
	City struct {
		Name string `json:"name,omitempty"` // 城市名称
	} `json:"city,omitempty"`
	Location struct {
		TimeZone  string  `json:"time_zone,omitempty"` // 位置时区
		Latitude  float64 `json:"latitude,omitempty"`  // 坐标纬度
		Longitude float64 `json:"longitude,omitempty"` // 坐标经度
	} `json:"location,omitempty"`
}

QueryCityResult 返回

Jump to

Keyboard shortcuts

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