ip

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	Region       = "Region"
	City         = "City"
	Country      = "Country"
	Isp          = "Isp"
	CountryCode  = "CountryCode"
	Latitude     = "Latitude"
	Longitude    = "Longitude"
	DistrictCode = "DistrictCode"
)
View Source
const Name = "IP"
View Source
const Null = "N/A"

Variables

View Source
var ErrInvalidIP = errors.New("invalid IP format")

Functions

This section is empty.

Types

type ErrInvalidFile added in v1.5.0

type ErrInvalidFile struct {
	Format string
	Reason string
}

func (ErrInvalidFile) Error added in v1.5.0

func (e ErrInvalidFile) Error() string

type LocationInfo added in v1.5.0

type LocationInfo struct {
	Country      string
	Region       string
	City         string
	Isp          string
	CountryCode  string
	Latitude     string
	Longitude    string
	DistrictCode string
}

LocationInfo stores IP location information.

type Locator added in v1.5.0

type Locator interface {
	Find(string) (*LocationInfo, error)
	Close() error
}

Locator represents an IP information loc.

func NewLocator added in v1.5.0

func NewLocator(dataFile, language string) (Locator, error)

NewLocator returns a new IP locator based on extension of given data file.

type LocatorStore added in v1.5.2

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

LocatorStore 按照文件路径保存了对应的 Locator,避免重复实例化浪费内存

func (*LocatorStore) Get added in v1.5.2

func (s *LocatorStore) Get(fpath string) Locator

Get 返回对应路径的 Locator 并将其引用计数加 1,如果 Locator 不存在则返回 nil

func (*LocatorStore) Remove added in v1.5.2

func (s *LocatorStore) Remove(fpath string)

Remove 将指定路径的 Locator 引用计数减 1 并在为零时从 Store 中移除

func (*LocatorStore) Set added in v1.5.2

func (s *LocatorStore) Set(fpath string, loc Locator)

Set 将 Locator 按照指定路径保存到 Store 中

type Number2Ip added in v1.5.0

type Number2Ip struct {
	Key string `json:"key"`
	New string `json:"new"`
	// contains filtered or unexported fields
}

func (*Number2Ip) ConfigOptions added in v1.5.0

func (g *Number2Ip) ConfigOptions() []Option

func (*Number2Ip) Description added in v1.5.0

func (g *Number2Ip) Description() string

func (*Number2Ip) RawTransform added in v1.5.0

func (g *Number2Ip) RawTransform(datas []string) ([]string, error)

func (*Number2Ip) SampleConfig added in v1.5.0

func (g *Number2Ip) SampleConfig() string

func (*Number2Ip) SetStats added in v1.5.1

func (g *Number2Ip) SetStats(err string) StatsInfo

func (*Number2Ip) Stage added in v1.5.0

func (g *Number2Ip) Stage() string

func (*Number2Ip) Stats added in v1.5.0

func (g *Number2Ip) Stats() StatsInfo

func (*Number2Ip) Transform added in v1.5.0

func (g *Number2Ip) Transform(datas []Data) ([]Data, error)

func (*Number2Ip) Type added in v1.5.0

func (g *Number2Ip) Type() string

type Transformer added in v1.5.0

type Transformer struct {
	StageTime   string `json:"stage"`
	Key         string `json:"key"`
	DataPath    string `json:"data_path"`
	KeyAsPrefix bool   `json:"key_as_prefix"`
	Language    string `json:"language"`
	// contains filtered or unexported fields
}

func (*Transformer) Close added in v1.5.2

func (t *Transformer) Close() error

func (*Transformer) ConfigOptions added in v1.5.0

func (_ *Transformer) ConfigOptions() []Option

func (*Transformer) Description added in v1.5.0

func (_ *Transformer) Description() string

func (*Transformer) Init added in v1.5.2

func (t *Transformer) Init() error

func (*Transformer) RawTransform added in v1.5.0

func (_ *Transformer) RawTransform(datas []string) ([]string, error)

func (*Transformer) SampleConfig added in v1.5.0

func (_ *Transformer) SampleConfig() string

func (*Transformer) SetMapValue added in v1.5.2

func (t *Transformer) SetMapValue(m map[string]interface{}, val interface{}, keys ...string) error

通过层级key设置value值, 如果keys不存在则不加前缀,否则加前缀

func (*Transformer) SetStats added in v1.5.1

func (t *Transformer) SetStats(err string) StatsInfo

func (*Transformer) Stage added in v1.5.0

func (t *Transformer) Stage() string

func (*Transformer) Stats added in v1.5.0

func (t *Transformer) Stats() StatsInfo

func (*Transformer) Transform added in v1.5.0

func (t *Transformer) Transform(datas []Data) ([]Data, error)

func (*Transformer) Type added in v1.5.0

func (_ *Transformer) Type() string

Jump to

Keyboard shortcuts

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