geoip

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DBFileContentType_name name map
	DBFileContentType_name = map[DBFileContentType]string{
		IPv4Content: "ipv4",
	}

	// DBFileContentType_value value map
	DBFileContentType_value = map[string]DBFileContentType{
		"ipv4": IPv4Content,
	}
)

Functions

func AddressCount

func AddressCount(network *net.IPNet) uint64

AddressCount returns the number of distinct host addresses within the given CIDR range.

Since the result is a uint64, this function returns meaningful information only for IPv4 ranges and IPv6 ranges with a prefix size of at least 65.

func AddressRange

func AddressRange(network *net.IPNet) (net.IP, net.IP)

AddressRange returns the first and last addresses in the given CIDR range.

func IPToInt

func IPToInt(ip net.IP) (*big.Int, int)

IPToInt todo

func IntToIP

func IntToIP(ipInt *big.Int, bits int) net.IP

IntToIP todo

Types

type DBFileContentType

type DBFileContentType uint

DBFileContentType 数据文件内容类型

const (
	// IPv4Content (ipv4) ipv4 文件
	IPv4Content DBFileContentType = iota
	// LocationContent (location) ip 地域信息
	LocationContent
)

func ParseDBFileContentType

func ParseDBFileContentType(str string) (DBFileContentType, error)

ParseDBFileContentType Parse DBFileContentType from string

func ParseDBFileContentTypeFromString

func ParseDBFileContentTypeFromString(str string) (DBFileContentType, error)

ParseDBFileContentTypeFromString Parse DBFileContentType from string

func (DBFileContentType) Equal

func (t DBFileContentType) Equal(target DBFileContentType) bool

Equal type compare

func (DBFileContentType) IsIn

func (t DBFileContentType) IsIn(targets ...DBFileContentType) bool

IsIn todo

func (DBFileContentType) MarshalJSON

func (t DBFileContentType) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (DBFileContentType) String

func (t DBFileContentType) String() string

String stringer

func (*DBFileContentType) UnmarshalJSON

func (t *DBFileContentType) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type IPv4

type IPv4 struct {
	Network             string  `bson:"_id" json:"network"`
	GeonameID           string  `bson:"geoname_id" json:"geoname_id"`
	First               string  `bson:"fist" json:"first"`
	Last                string  `bson:"last" json:"last"`
	Start               uint64  `bson:"start" json:"start"`
	End                 uint64  `bson:"end" json:"end"`
	Count               uint64  `bson:"count" json:"count"`
	Latitude            float64 `bson:"latitude" json:"latitude"`
	Longitude           float64 `bson:"longitude" json:"longitude"`
	AccuracyRadius      int64   `bson:"accuracy_radius" json:"accuracy_radius"`
	IsAnonymousProxy    bool    `bson:"is_anonymous_proxy" json:"is_anonymous_proxy"`
	IsSatelliteProvider bool    `bson:"is_satellite_provider" json:"is_satellite_provider"`
	ISP                 string  `bson:"isp" json:"isp"`
}

IPv4 todo

func NewDefaultIPv4

func NewDefaultIPv4() *IPv4

NewDefaultIPv4 todo

func ParseIPv4FromCsvLine

func ParseIPv4FromCsvLine(line string) (*IPv4, error)

ParseIPv4FromCsvLine todo

func (*IPv4) ParseAccuracyRadius

func (i *IPv4) ParseAccuracyRadius(radius string)

ParseAccuracyRadius todo

func (*IPv4) ParseIsAnonymousProxy

func (i *IPv4) ParseIsAnonymousProxy(is string)

ParseIsAnonymousProxy todo

func (*IPv4) ParseIsSatelliteProvider

func (i *IPv4) ParseIsSatelliteProvider(is string)

ParseIsSatelliteProvider tood

func (*IPv4) ParseLatitude

func (i *IPv4) ParseLatitude(lat string)

ParseLatitude todo

func (*IPv4) ParseLongitude

func (i *IPv4) ParseLongitude(lon string)

ParseLongitude todo

type IPv4Set

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

IPv4Set todo

func NewIPv4Set

func NewIPv4Set(capacity uint) *IPv4Set

NewIPv4Set todo

func (*IPv4Set) Add

func (s *IPv4Set) Add(item *IPv4)

Add todo

func (*IPv4Set) IsFull

func (s *IPv4Set) IsFull() bool

IsFull todo

func (*IPv4Set) Items

func (s *IPv4Set) Items() []*IPv4

Items tood

func (*IPv4Set) Length

func (s *IPv4Set) Length() uint

Length tood

func (*IPv4Set) Reset

func (s *IPv4Set) Reset()

Reset todo

type Location

type Location struct {
	GeonameID      string `bson:"_id" json:"geoname_id"`
	LocaleCode     string `bson:"locale_code" json:"locale_code"`
	ContinentCode  string `bson:"continent_code" json:"continent_code"`
	ContinentName  string `bson:"continent_name" json:"continent_name"`
	CountryISOCode string `bson:"country_iso_code" json:"country_iso_code"`
	CountryName    string `bson:"country_name" json:"country_name"`
	CityName       string `bson:"city_name" json:"city_name"`
}

Location todo

func NewDefaultLocation

func NewDefaultLocation() *Location

NewDefaultLocation todo

func ParseLocationFromCsvLine

func ParseLocationFromCsvLine(line string) (*Location, error)

ParseLocationFromCsvLine todo

type LocationSet

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

LocationSet todo

func NewLocationSet

func NewLocationSet(capacity uint) *LocationSet

NewLocationSet todo

func (*LocationSet) Add

func (s *LocationSet) Add(item *Location)

Add todo

func (*LocationSet) IsFull

func (s *LocationSet) IsFull() bool

IsFull todo

func (*LocationSet) Items

func (s *LocationSet) Items() []*Location

Items todo

func (*LocationSet) Length

func (s *LocationSet) Length() uint

Length tood

func (*LocationSet) Reset

func (s *LocationSet) Reset()

Reset todo

type Record

type Record struct {
	*IPv4     `bson:",inline"`
	*Location `bson:",inline"`
}

Record todo

func NewRecord

func NewRecord(ipv4 *IPv4, location *Location) *Record

NewRecord todo

type Service

type Service interface {
	UpdateDBFile(*UpdateDBFileRequest) error
	LookupIP(ipAddress net.IP) (*Record, error)
}

Service todo

type UpdateDBFileRequest

type UpdateDBFileRequest struct {
	*session.Session

	ContentType DBFileContentType
	// contains filtered or unexported fields
}

UpdateDBFileRequest 上传文件请求

func NewUploadFileRequestFromHTTP

func NewUploadFileRequestFromHTTP(r *http.Request) (*UpdateDBFileRequest, error)

NewUploadFileRequestFromHTTP todo

func (*UpdateDBFileRequest) ReadCloser

func (req *UpdateDBFileRequest) ReadCloser() io.ReadCloser

ReadCloser todo

func (*UpdateDBFileRequest) Validate

func (req *UpdateDBFileRequest) Validate() error

Validate 校验参数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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