ip_location

package module
v0.0.0-...-01b6caf Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 9 Imported by: 0

README

ip_location

介绍

根据ip获取location(国家、城市、区号等)信息 需要结合QQwry纯真IP数据库

获取纯真IP库

访问 http://www.cz88.net 下载纯真IP库

使用
    go get gitee.com/dh114007/ip_location
demo
    IPDict := NewIPDict()
    IPDict.Load("./qqwry.dat")
    res := IPDict.FindIP("127.0.0.1")
    log.Println(res)

Documentation

Index

Constants

View Source
const (
	// DefaultDict 默认字典
	DefaultDict = "./qqwry.dat"
	// IndexLen 索引长度
	IndexLen = 7
	// RedirectMode1 国家的类型, 指向另一个指向
	RedirectMode1 = 0x01
	// RedirectMode2 国家的类型, 指向一个指向
	RedirectMode2 = 0x02
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IPDict

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

func NewIPDict

func NewIPDict() *IPDict

func (*IPDict) FindIP

func (q *IPDict) FindIP(ip string) (*IPLocation, error)

func (*IPDict) Load

func (q *IPDict) Load(fileName string) error

type IPLocation

type IPLocation struct {
	IP      string `json:"ip"`
	BeginIP string `json:"begin_ip"`
	EndIP   string `json:"end_ip"`
	Country string `json:"country"`
	Area    string `json:"area"`
}

Jump to

Keyboard shortcuts

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