Documentation
¶
Index ¶
- func DefaultIPLibraryData() []byte
- func HashRegion(countryId uint16, provinceId uint16, cityId uint32, townId uint32, ...) string
- func InitDefault() error
- func LookupIPSummaries(ipList []string) map[string]string
- type City
- type Country
- type Encrypt
- type FileReader
- type FileWriter
- type IPLibrary
- type Meta
- func (this *Meta) CityWithId(cityId uint32) *City
- func (this *Meta) CountryWithId(countryId uint16) *Country
- func (this *Meta) Init()
- func (this *Meta) ProviderWithId(providerId uint16) *Provider
- func (this *Meta) ProvinceWithId(provinceId uint16) *Province
- func (this *Meta) TownWithId(townId uint32) *Town
- type Parser
- type ParserConfig
- type Provider
- type Province
- type QueryResult
- func (this *QueryResult) CityId() int64
- func (this *QueryResult) CityName() string
- func (this *QueryResult) CountryCodes() []string
- func (this *QueryResult) CountryId() int64
- func (this *QueryResult) CountryName() string
- func (this *QueryResult) IsOk() bool
- func (this *QueryResult) ProviderCodes() []string
- func (this *QueryResult) ProviderId() int64
- func (this *QueryResult) ProviderName() string
- func (this *QueryResult) ProvinceCodes() []string
- func (this *QueryResult) ProvinceId() int64
- func (this *QueryResult) ProvinceName() string
- func (this *QueryResult) RegionSummary() string
- func (this *QueryResult) Summary() string
- func (this *QueryResult) TownId() int64
- func (this *QueryResult) TownName() string
- type Reader
- type ReaderInterface
- type ReaderParser
- type ReaderV2
- type ReaderVersion
- type Template
- type Town
- type Updater
- type UpdaterSource
- type Version
- type WriterInterface
- type WriterV1
- type WriterV2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultIPLibraryData ¶ added in v0.5.2
func DefaultIPLibraryData() []byte
func HashRegion ¶ added in v0.5.2
func LookupIPSummaries ¶ added in v1.2.9
LookupIPSummaries 查询一组IP对应的区域描述
Types ¶
type Encrypt ¶ added in v1.0.0
type Encrypt struct { }
func NewEncrypt ¶ added in v1.0.0
func NewEncrypt() *Encrypt
type FileReader ¶
type FileReader struct {
// contains filtered or unexported fields
}
func NewFileDataReader ¶ added in v0.5.2
func NewFileDataReader(dataReader io.Reader, password string, readerVersion ReaderVersion) (*FileReader, error)
func NewFileReader ¶
func NewFileReader(path string, password string) (*FileReader, error)
func (*FileReader) Lookup ¶
func (this *FileReader) Lookup(ip net.IP) *QueryResult
func (*FileReader) Meta ¶
func (this *FileReader) Meta() *Meta
func (*FileReader) RawReader ¶ added in v0.5.2
func (this *FileReader) RawReader() ReaderInterface
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
func NewFileWriter ¶
func NewFileWriter(path string, meta *Meta, password string) (*FileWriter, error)
func (*FileWriter) Close ¶
func (this *FileWriter) Close() error
func (*FileWriter) Sum ¶
func (this *FileWriter) Sum() string
func (*FileWriter) WriteMeta ¶
func (this *FileWriter) WriteMeta() error
type IPLibrary ¶ added in v0.5.2
type IPLibrary struct {
// contains filtered or unexported fields
}
func NewIPLibrary ¶ added in v0.5.2
func NewIPLibrary() *IPLibrary
func NewIPLibraryWithReader ¶ added in v0.5.2
func NewIPLibraryWithReader(reader ReaderInterface) *IPLibrary
func (*IPLibrary) InitFromData ¶ added in v0.5.2
func (this *IPLibrary) InitFromData(data []byte, password string, version ReaderVersion) error
func (*IPLibrary) LookupIP ¶ added in v0.5.2
func (this *IPLibrary) LookupIP(ip string) *QueryResult
type Meta ¶
type Meta struct { Version int `json:"version"` // IP库版本 Code string `json:"code"` // 代号,用来区分不同的IP库 Author string `json:"author"` Countries []*Country `json:"countries"` Provinces []*Province `json:"provinces"` Cities []*City `json:"cities"` Towns []*Town `json:"towns"` Providers []*Provider `json:"providers"` CreatedAt int64 `json:"createdAt"` // contains filtered or unexported fields }
func (*Meta) CityWithId ¶
func (*Meta) CountryWithId ¶
func (*Meta) ProviderWithId ¶
func (*Meta) ProvinceWithId ¶
func (*Meta) TownWithId ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewParser ¶
func NewParser(config *ParserConfig) (*Parser, error)
type ParserConfig ¶
type QueryResult ¶
type QueryResult struct {
// contains filtered or unexported fields
}
func (*QueryResult) CityId ¶
func (this *QueryResult) CityId() int64
func (*QueryResult) CityName ¶
func (this *QueryResult) CityName() string
func (*QueryResult) CountryCodes ¶ added in v0.5.2
func (this *QueryResult) CountryCodes() []string
func (*QueryResult) CountryId ¶
func (this *QueryResult) CountryId() int64
func (*QueryResult) CountryName ¶
func (this *QueryResult) CountryName() string
func (*QueryResult) IsOk ¶
func (this *QueryResult) IsOk() bool
func (*QueryResult) ProviderCodes ¶ added in v0.5.2
func (this *QueryResult) ProviderCodes() []string
func (*QueryResult) ProviderId ¶
func (this *QueryResult) ProviderId() int64
func (*QueryResult) ProviderName ¶
func (this *QueryResult) ProviderName() string
func (*QueryResult) ProvinceCodes ¶ added in v0.5.2
func (this *QueryResult) ProvinceCodes() []string
func (*QueryResult) ProvinceId ¶
func (this *QueryResult) ProvinceId() int64
func (*QueryResult) ProvinceName ¶
func (this *QueryResult) ProvinceName() string
func (*QueryResult) RegionSummary ¶ added in v1.2.9
func (this *QueryResult) RegionSummary() string
func (*QueryResult) Summary ¶ added in v0.5.2
func (this *QueryResult) Summary() string
func (*QueryResult) TownId ¶
func (this *QueryResult) TownId() int64
func (*QueryResult) TownName ¶
func (this *QueryResult) TownName() string
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader IP库Reader
func NewReaderV1 ¶ added in v1.3.5
NewReaderV1 创建新Reader对象
type ReaderInterface ¶ added in v1.3.5
type ReaderInterface interface { Meta() *Meta Lookup(ip net.IP) *QueryResult Destroy() }
type ReaderParser ¶
type ReaderParser struct {
// contains filtered or unexported fields
}
func NewReaderParser ¶
func NewReaderParser(reader io.Reader, config *ParserConfig) (*ReaderParser, error)
func (*ReaderParser) Parse ¶
func (this *ReaderParser) Parse() error
type ReaderV2 ¶ added in v1.3.5
type ReaderV2 struct {
// contains filtered or unexported fields
}
ReaderV2 IP库Reader V2
func NewReaderV2 ¶ added in v1.3.5
NewReaderV2 创建新Reader对象
type ReaderVersion ¶ added in v1.3.5
type ReaderVersion = int
const ( ReaderVersionV1 ReaderVersion = 0 ReaderVersionV2 ReaderVersion = 2 )
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
func NewTemplate ¶
type Updater ¶ added in v0.5.2
type Updater struct {
// contains filtered or unexported fields
}
func NewUpdater ¶ added in v0.5.2
func NewUpdater(source UpdaterSource, interval time.Duration) *Updater
type UpdaterSource ¶ added in v0.5.2
type WriterInterface ¶ added in v1.3.5
type WriterV1 ¶ added in v1.3.5
type WriterV1 struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.