ip2region

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoCache     = 0
	VIndexCache = 1
	BufferCache = 2
)

Variables

This section is empty.

Functions

func CachePolicyFromName

func CachePolicyFromName(name string) (int, error)

Types

type Client

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

func NewClient

func NewClient() (*Client, error)

func (*Client) Close

func (g *Client) Close()

func (*Client) Query

func (g *Client) Query(rawIP string) (ret geoip.Result, err error)

type Config

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

func NewV4Config

func NewV4Config(cachePolicy int, xdbContent []byte, searchers int) (*Config, error)

func NewV6Config

func NewV6Config(cachePolicy int, xdbContent []byte, searchers int) (*Config, error)

func (*Config) CBuffer

func (c *Config) CBuffer() []byte

func (*Config) CachePolicy

func (c *Config) CachePolicy() int

func (*Config) Header

func (c *Config) Header() *xdb.Header

func (*Config) IPVersion

func (c *Config) IPVersion() *xdb.Version

func (*Config) Searchers

func (c *Config) Searchers() int

func (*Config) String

func (c *Config) String() string

func (*Config) VIndex

func (c *Config) VIndex() []byte

type Ip2Region

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

func NewIp2Region

func NewIp2Region(v4Config *Config, v6Config *Config) (*Ip2Region, error)

NewIp2Region create a new Ip2Region service with specified v4 and v6 config. set it to nil to disable the specified search for the specified version.

func (*Ip2Region) Close

func (ip2r *Ip2Region) Close()

func (*Ip2Region) CloseTimeout

func (ip2r *Ip2Region) CloseTimeout(d time.Duration)

func (*Ip2Region) Search

func (ip2r *Ip2Region) Search(ipBytes []byte) (string, error)

func (*Ip2Region) SearchByStr

func (ip2r *Ip2Region) SearchByStr(ipStr string) (string, error)

type SearcherPool

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

func NewSearcherPool

func NewSearcherPool(config *Config) (*SearcherPool, error)

func (*SearcherPool) BorrowSearcher

func (sp *SearcherPool) BorrowSearcher() *xdb.Searcher

func (*SearcherPool) Close

func (sp *SearcherPool) Close()

func (*SearcherPool) CloseTimeout

func (sp *SearcherPool) CloseTimeout(d time.Duration)

func (*SearcherPool) LoanCount

func (sp *SearcherPool) LoanCount() int

LoanCount get the loaned count

func (*SearcherPool) ReturnSearcher

func (sp *SearcherPool) ReturnSearcher(searcher *xdb.Searcher)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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