Documentation
¶
Index ¶
- Constants
- Variables
- func IntToBinaryBE(num, length int) []byte
- type Meta
- type Reader
- type Writer
- func (w *Writer) Fields(fields []string) int
- func (w *Writer) Insert(info *model.IPInfo) error
- func (w *Writer) Nodes(ip net.IP, mask int) (node, index int, ok bool)
- func (w *Writer) Resolve(offset int) string
- func (w *Writer) SetOption(option interface{}) error
- func (w *Writer) WriteTo(iw io.Writer) (int64, error)
- type WriterOption
Constants ¶
View Source
const ( FieldCountryName = "country_name" FieldRegionName = "region_name" FieldCityName = "city_name" FieldISPDomain = "isp_domain" FieldContinentCode = "continent_code" FieldUTCOffset = "utc_offset" FieldLatitude = "latitude" FieldLongitude = "longitude" FieldChinaAdminCode = "china_admin_code" FieldOwnerDomain = "owner_domain" FieldTimezone = "timezone" FieldIddCode = "idd_code" FieldCountryCode = "country_code" FieldIDC = "idc" FieldBaseStation = "base_station" FieldCountryCode3 = "country_code3" FieldEuropeanUnion = "european_union" FieldCurrencyCode = "currency_code" FieldCurrencyName = "currency_name" FieldAnycast = "anycast" )
View Source
const ( DBFormat = "ipdb" DBExt = ".ipdb" )
View Source
const (
FieldsSep = "\t"
)
Variables ¶
View Source
var CommonFieldsAlias = map[string]string{ model.Country: FieldCountryName, model.Province: FieldRegionName, model.City: FieldCityName, model.ISP: FieldISPDomain, model.Continent: FieldContinentCode, model.UTCOffset: FieldUTCOffset, model.Latitude: FieldLatitude, model.Longitude: FieldLongitude, model.ChinaAdminCode: FieldChinaAdminCode, }
CommonFieldsAlias 公共字段到数据库字段映射
View Source
var FullFields = []string{ FieldCountryName, FieldRegionName, FieldCityName, FieldISPDomain, FieldContinentCode, FieldUTCOffset, FieldLatitude, FieldLongitude, FieldChinaAdminCode, FieldOwnerDomain, FieldTimezone, FieldIddCode, FieldCountryCode, FieldIDC, FieldBaseStation, FieldCountryCode3, FieldEuropeanUnion, FieldCurrencyCode, FieldCurrencyName, FieldAnycast, }
FullFields 全字段列表
Functions ¶
func IntToBinaryBE ¶
IntToBinaryBE 将int转换为 binary big endian
Types ¶
type Meta ¶
type Meta struct {
// Build 构建时间 10位时间戳
Build int `json:"build"`
// IPVersion IP库版本
IPVersion int `json:"ip_version"`
// Languages 支持语言
// value为语言对应的fields偏移量
Languages map[string]int `json:"languages"`
// NodeCount 节点数量
NodeCount int `json:"node_count"`
// TotalSize 节点区域和数据区域大小统计
TotalSize int `json:"total_size"`
// Fields 数据字段列表
// 城市级别数据库包含13个字段
// "country_name": "国家名称"
// "region_name": "省份名称"
// "city_name": "城市名称"
// "owner_domain": "所有者"
// "isp_domain": "运营商"
// "latitude": "纬度"
// "longitude": "经度"
// "timezone": "时区"
// "utc_offset": "UTC偏移量"
// "china_admin_code": "中国邮编"
// "idd_code": "电话区号"
// "country_code": "国家代码"
// "continent_code": "大陆代码"
Fields []string `json:"fields"`
}
Meta ipdb 元数据
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a structure that provides functionalities to read from IPDB IP database.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer provides functionalities to write IP data into IPDB format.
type WriterOption ¶
type WriterOption struct {
// Languages specifies multiple languages for the IPDB format.
Languages map[string]int
}
WriterOption provides options for the Writer.
Click to show internal directories.
Click to hide internal directories.