Documentation
¶
Index ¶
- Constants
- Variables
- type ASNInfo
- type BaseStation
- func (db *BaseStation) BatchFind(addrs []string, language string) []BatchResult
- func (db *BaseStation) BuildTime() time.Time
- func (db *BaseStation) Fields() []string
- func (db *BaseStation) Find(addr, language string) ([]string, error)
- func (db *BaseStation) FindInfo(addr, language string) (*BaseStationInfo, error)
- func (db *BaseStation) FindMap(addr, language string) (map[string]string, error)
- func (db *BaseStation) IsIPv4() bool
- func (db *BaseStation) IsIPv6() bool
- func (db *BaseStation) Languages() []string
- func (db *BaseStation) Reload(name string) error
- type BaseStationInfo
- type BatchResult
- type City
- func (db *City) BuildTime() time.Time
- func (db *City) ClearCache()
- func (db *City) Fields() []string
- func (db *City) Find(addr, language string) ([]string, error)
- func (db *City) FindInfo(addr, language string) (*CityInfo, error)
- func (db *City) FindMap(addr, language string) (map[string]string, error)
- func (db *City) IsIPv4() bool
- func (db *City) IsIPv6() bool
- func (db *City) Languages() []string
- func (db *City) Reload(name string) error
- type CityInfo
- type District
- func (db *District) BuildTime() time.Time
- func (db *District) ClearCache()
- func (db *District) Fields() []string
- func (db *District) Find(addr, language string) ([]string, error)
- func (db *District) FindInfo(addr, language string) (*DistrictInfo, error)
- func (db *District) FindMap(addr, language string) (map[string]string, error)
- func (db *District) IsIPv4() bool
- func (db *District) IsIPv6() bool
- func (db *District) Languages() []string
- func (db *District) Reload(name string) error
- type DistrictInfo
- type Download
- type IDC
- func (db *IDC) BuildTime() time.Time
- func (db *IDC) ClearCache()
- func (db *IDC) Fields() []string
- func (db *IDC) Find(addr, language string) ([]string, error)
- func (db *IDC) FindInfo(addr, language string) (*IDCInfo, error)
- func (db *IDC) FindMap(addr, language string) (map[string]string, error)
- func (db *IDC) IsIPv4() bool
- func (db *IDC) IsIPv6() bool
- func (db *IDC) Languages() []string
- func (db *IDC) Reload(name string) error
- type IDCInfo
- type IPInfo
- type MetaData
- type ProgressFunc
- type Risk
- type RiskInfo
- type WriteCounter
Constants ¶
View Source
const ( IPv4 = 0x01 IPv6 = 0x02 )
Variables ¶
View Source
var ( ErrInvalidIP = errors.New("无效的IP地址") ErrNotFound = errors.New("未找到IP信息") )
View Source
var ( ErrFileSize = errors.New("IP数据库文件大小错误") ErrMetaData = errors.New("IP数据库元数据错误") ErrReadFull = errors.New("IP数据库读取错误") ErrDatabase = errors.New("数据库错误") ErrIPFormat = errors.New("IP地址格式错误") ErrNoSupportLanguage = errors.New("不支持该语言") ErrNoSupportIPv4 = errors.New("不支持IPv4") ErrNoSupportIPv6 = errors.New("不支持IPv6") ErrDataNotExists = errors.New("数据不存在") )
Functions ¶
This section is empty.
Types ¶
type BaseStation ¶
type BaseStation struct {
// contains filtered or unexported fields
}
BaseStation 基站数据库结构体
func NewBaseStation ¶
func NewBaseStation(name string) (*BaseStation, error)
NewBaseStation 创建新的基站数据库实例
func (*BaseStation) BatchFind ¶ added in v0.1.0
func (db *BaseStation) BatchFind(addrs []string, language string) []BatchResult
func (*BaseStation) Find ¶
func (db *BaseStation) Find(addr, language string) ([]string, error)
Find 查找IP地址对应的基站信息(字符串切片形式)
func (*BaseStation) FindInfo ¶
func (db *BaseStation) FindInfo(addr, language string) (*BaseStationInfo, error)
FindInfo 查找IP地址对应的基站信息(结构体形式)
type BaseStationInfo ¶
type BaseStationInfo struct { CountryName string `json:"country_name"` RegionName string `json:"region_name"` CityName string `json:"city_name"` OwnerDomain string `json:"owner_domain"` IspDomain string `json:"isp_domain"` BaseStation string `json:"base_station"` }
BaseStationInfo 存储基站信息的结构体
func (*BaseStationInfo) GetCityName ¶ added in v0.1.0
func (b *BaseStationInfo) GetCityName() string
func (*BaseStationInfo) GetCountryName ¶ added in v0.1.0
func (b *BaseStationInfo) GetCountryName() string
让 BaseStationInfo 实现 IPInfo 接口
func (*BaseStationInfo) GetRegionName ¶ added in v0.1.0
func (b *BaseStationInfo) GetRegionName() string
type BatchResult ¶ added in v0.1.0
type BatchResult struct { IP string Info *BaseStationInfo Error error }
type City ¶
type City struct {
// contains filtered or unexported fields
}
City struct
func NewCityFromBytes ¶
NewCityFromBytes initialize from bytes
func (*City) ClearCache ¶ added in v0.1.0
func (db *City) ClearCache()
ClearCache clears the internal cache
type CityInfo ¶
type CityInfo struct { CountryName string `json:"country_name"` RegionName string `json:"region_name"` CityName string `json:"city_name"` DistrictName string `json:"district_name"` OwnerDomain string `json:"owner_domain"` IspDomain string `json:"isp_domain"` Latitude string `json:"latitude"` Longitude string `json:"longitude"` Timezone string `json:"timezone"` UtcOffset string `json:"utc_offset"` ChinaRegionCode string `json:"china_region_code"` ChinaCityCode string `json:"china_city_code"` ChinaDistrictCode string `json:"china_district_code"` ChinaAdminCode string `json:"china_admin_code"` IddCode string `json:"idd_code"` CountryCode string `json:"country_code"` ContinentCode string `json:"continent_code"` IDC string `json:"idc"` BaseStation string `json:"base_station"` CountryCode3 string `json:"country_code3"` EuropeanUnion string `json:"european_union"` CurrencyCode string `json:"currency_code"` CurrencyName string `json:"currency_name"` Anycast string `json:"anycast"` Line string `json:"line"` DistrictInfo DistrictInfo `json:"district_info"` Route string `json:"route"` ASN string `json:"asn"` ASNInfo []ASNInfo `json:"asn_info"` AreaCode string `json:"area_code"` UsageType string `json:"usage_type"` }
CityInfo is City Database Content
type District ¶
type District struct {
// contains filtered or unexported fields
}
func NewDistrict ¶
func (*District) FindInfo ¶
func (db *District) FindInfo(addr, language string) (*DistrictInfo, error)
type DistrictInfo ¶
type DistrictInfo struct { CountryName string `json:"country_name"` RegionName string `json:"region_name"` CityName string `json:"city_name"` DistrictName string `json:"district_name"` ChinaAdminCode string `json:"china_admin_code"` CoveringRadius string `json:"covering_radius"` Latitude string `json:"latitude"` Longitude string `json:"longitude"` }
type Download ¶ added in v0.1.0
Download 结构体用于处理文件下载
func NewDownload ¶ added in v0.1.0
NewDownload 创建新的下载实例
func (*Download) SaveToFile ¶ added in v0.1.0
func (dl *Download) SaveToFile(fn string, progress ProgressFunc) error
SaveToFile 将URL指向的文件下载到指定路径
type IDC ¶ added in v0.1.0
type IDC struct {
// contains filtered or unexported fields
}
func (*IDC) ClearCache ¶ added in v0.1.0
func (db *IDC) ClearCache()
type ProgressFunc ¶ added in v0.1.0
type ProgressFunc func(current, total int64)
Progress 用于跟踪下载进度的回调函数类型
type Risk ¶ added in v0.1.0
type Risk struct {
// contains filtered or unexported fields
}
Risk 风险数据库结构
type RiskInfo ¶ added in v0.1.0
type RiskInfo struct { Score int `json:"score"` // 风险分数 Behavior string `json:"behavior"` // 行为类型 CountryCode string `json:"country_code"` // 国家代码 }
RiskInfo 存储IP风险信息
type WriteCounter ¶ added in v0.1.0
type WriteCounter struct { Current int64 Total int64 Progress ProgressFunc }
WriteCounter 用于跟踪写入进度
Click to show internal directories.
Click to hide internal directories.