iplibrary

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: BSD-3-Clause Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type City

type City struct {
	Id    int64    `json:"id"`
	Name  string   `json:"name"`
	Codes []string `json:"codes"`
}

type Country

type Country struct {
	Id    int64    `json:"id"`
	Name  string   `json:"name"`
	Codes []string `json:"codes"`
}

type FileReader

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

func NewFileReader

func NewFileReader(path string) (*FileReader, error)

func (*FileReader) Lookup

func (this *FileReader) Lookup(ip net.IP) *QueryResult

func (*FileReader) Meta

func (this *FileReader) Meta() *Meta

type FileWriter

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

func NewFileWriter

func NewFileWriter(path string, meta *Meta) (*FileWriter, error)

func (*FileWriter) Close

func (this *FileWriter) Close() error

func (*FileWriter) Sum

func (this *FileWriter) Sum() string

func (*FileWriter) Write

func (this *FileWriter) Write(ipFrom string, ipTo string, countryId int64, provinceId int64, cityId int64, townId int64, providerId int64) error

func (*FileWriter) WriteMeta

func (this *FileWriter) WriteMeta() error

type Meta

type Meta struct {
	Version   int         `json:"version"` // 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 (this *Meta) CityWithId(cityId int64) *City

func (*Meta) CountryWithId

func (this *Meta) CountryWithId(countryId int64) *Country

func (*Meta) Init

func (this *Meta) Init()

func (*Meta) ProviderWithId

func (this *Meta) ProviderWithId(providerId int64) *Provider

func (*Meta) ProvinceWithId

func (this *Meta) ProvinceWithId(provinceId int64) *Province

func (*Meta) TownWithId

func (this *Meta) TownWithId(townId int64) *Town

type Parser

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

func NewParser

func NewParser(config *ParserConfig) (*Parser, error)

func (*Parser) Parse

func (this *Parser) Parse() error

func (*Parser) Write

func (this *Parser) Write(data []byte)

type ParserConfig

type ParserConfig struct {
	Template    *Template
	EmptyValues []string
	Iterator    func(values map[string]string) error
}

type Provider

type Provider struct {
	Id    int64    `json:"id"`
	Name  string   `json:"name"`
	Codes []string `json:"codes"`
}

type Province

type Province struct {
	Id    int64    `json:"id"`
	Name  string   `json:"name"`
	Codes []string `json:"codes"`
}

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) CountryId

func (this *QueryResult) CountryId() int64

func (*QueryResult) CountryName

func (this *QueryResult) CountryName() string

func (*QueryResult) IsOk

func (this *QueryResult) IsOk() bool

func (*QueryResult) ProviderId

func (this *QueryResult) ProviderId() int64

func (*QueryResult) ProviderName

func (this *QueryResult) ProviderName() string

func (*QueryResult) ProvinceId

func (this *QueryResult) ProvinceId() int64

func (*QueryResult) ProvinceName

func (this *QueryResult) ProvinceName() 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
}

func NewReader

func NewReader(reader io.Reader) (*Reader, error)

func (*Reader) IPv4Items

func (this *Reader) IPv4Items() []*ipItem

func (*Reader) IPv6Items

func (this *Reader) IPv6Items() []*ipItem

func (*Reader) Lookup

func (this *Reader) Lookup(ip net.IP) *QueryResult

func (*Reader) Meta

func (this *Reader) Meta() *Meta

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 Template

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

func NewTemplate

func NewTemplate(templateString string) (*Template, error)

func (*Template) Extract

func (this *Template) Extract(text string, emptyValues []string) (values map[string]string, ok bool)

type Town

type Town struct {
	Id    int64    `json:"id"`
	Name  string   `json:"name"`
	Codes []string `json:"codes"`
}

type Version

type Version = int
const (
	Version1 Version = 1
)

type Writer

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

func NewWriter

func NewWriter(writer io.Writer, meta *Meta) *Writer

func (*Writer) Sum

func (this *Writer) Sum() string

func (*Writer) Write

func (this *Writer) Write(ipFrom string, ipTo string, countryId int64, provinceId int64, cityId int64, townId int64, providerId int64) error

func (*Writer) WriteMeta

func (this *Writer) WriteMeta() error

Jump to

Keyboard shortcuts

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