iploc

package
v8.0.8 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: GPL-3.0, BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPLen = 4
)
View Source
const Version = "1.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Detail

type Detail struct {
	IP    IP
	Start IP
	End   IP
	Location
}

func Find

func Find(qqwrySrc, rawIP string) (*Detail, error)

Find shorthand for iploc.Open.Find not be preload file and without indexed

func (Detail) Bytes

func (detail Detail) Bytes() []byte

func (Detail) In

func (detail Detail) In(rawIP string) bool

func (Detail) InIP

func (detail Detail) InIP(ip IP) bool

func (Detail) InUint

func (detail Detail) InUint(uintIP uint32) bool

func (Detail) String

func (detail Detail) String() string

type IP

type IP [IPLen]byte

func ParseBytesIP

func ParseBytesIP(b []byte) (ip IP)

func ParseIP

func ParseIP(s string) (ip IP, err error)

func ParseUintIP

func ParseUintIP(u uint32) (ip IP)

func (IP) Bytes

func (ip IP) Bytes() []byte

func (IP) Compare

func (ip IP) Compare(a IP) int

Compare like bytes.Compare The result will be 0 if == a, -1 if < a, and +1 if > a.

func (IP) ReverseBytes

func (ip IP) ReverseBytes() []byte

func (IP) String

func (ip IP) String() string

func (IP) Uint

func (ip IP) Uint() uint32

type Location

type Location struct {
	Country  string
	Region   string
	Province string
	City     string
	County   string
	// contains filtered or unexported fields
}

func (Location) Bytes

func (location Location) Bytes() []byte

func (Location) GetCity

func (location Location) GetCity() string

func (Location) GetCountry

func (location Location) GetCountry() string

func (Location) GetCounty

func (location Location) GetCounty() string

func (Location) GetProvince

func (location Location) GetProvince() string

func (Location) GetRegion

func (location Location) GetRegion() string

func (Location) String

func (location Location) String() string

type LocationRaw

type LocationRaw struct {
	Text [2][]byte
	Pos  [2]uint32
	Mode [2]byte
}

type Locator

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

func Load

func Load(b []byte) (loc *Locator, err error)

func LoadWithoutIndexes

func LoadWithoutIndexes(b []byte) (loc *Locator, err error)

func Open

func Open(qqwrySrc string) (loc *Locator, err error)

Open 生成索引,查询速度快

func OpenWithoutIndexes

func OpenWithoutIndexes(qqwrySrc string) (loc *Locator, err error)

OpenWithoutIndexes 无索引,不预载文件,打开速度快,但查询速度慢

func (*Locator) Close

func (loc *Locator) Close() error

Close close the file descriptor, if there is no preload

func (*Locator) Count

func (loc *Locator) Count() int

func (*Locator) Find

func (loc *Locator) Find(rawIP string) *Detail

func (*Locator) FindIP

func (loc *Locator) FindIP(ip IP) *Detail

func (*Locator) FindUint

func (loc *Locator) FindUint(uintIP uint32) *Detail

func (*Locator) Range

func (loc *Locator) Range(iterator rangeIterator)

type Parser

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

func NewParser

func NewParser(qqwrySrc string, preload bool) (*Parser, error)

func NewParserRes

func NewParserRes(res resReadCloser, size uint32) (*Parser, error)

func (*Parser) Close

func (p *Parser) Close() error

func (*Parser) Count

func (p *Parser) Count() uint32

func (*Parser) IndexRange

func (p *Parser) IndexRange(iterator indexIterator)

(*Parser) IndexRange calls the iterator for every index within the range (i, start, end, Pos) until iterator returns false.

func (*Parser) ReadByte

func (p *Parser) ReadByte(pos int64) byte

(*Parser) ReadByte 读取1字节,用来识别重定向模式

func (*Parser) ReadBytes

func (p *Parser) ReadBytes(pos, n int64) (b []byte)

(*Parser) ReadBytes 读取n字节并翻转

func (*Parser) ReadLocationRaw

func (p *Parser) ReadLocationRaw(offset int64) (raw LocationRaw)

ReadLocationRaw 用于导出或索引

func (*Parser) ReadPosition

func (p *Parser) ReadPosition(offset int64) int64

(*Parser) ReadPosition 读取3字节的偏移位置

func (*Parser) ReadRegion

func (p *Parser) ReadRegion(offset int64) (s []byte)

(*Parser) ReadRegion 读取地区数据,处理可能的重定向

func (*Parser) ReadRegionString

func (p *Parser) ReadRegionString(offset int64) string

func (*Parser) ReadString

func (p *Parser) ReadString(offset int64) (string, int)

func (*Parser) ReadText

func (p *Parser) ReadText(offset int64) ([]byte, int)

(*Parser) ReadText 读取国家地区数据,以0x00结尾

func (*Parser) Reader

func (p *Parser) Reader() io.Reader

func (*Parser) Size

func (p *Parser) Size() uint32

Jump to

Keyboard shortcuts

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