Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CountryCode ¶
type CountryCode string
func (CountryCode) String ¶
func (cc CountryCode) String() string
type IPInfo ¶
type IPInfo struct { CountryCode CountryCode ASN int }
func GetIPInfoFromAddr ¶
GetIPInfoFromAddr is a helper function to extract the IP address from the net.Addr and call IPInfoMap.GetIPInfo. It uses special country codes to indicate errors:
- "XA": failed to extract the IP from the address ("A" is for "Address").
- "XL": IP is not global ("L" is for "Local").
- "XD": database error looking up the country code ("D" is for "DB").
- "ZZ": lookup returned an empty country code (same as the Unicode unknown location).
func GetIPInfoFromIP ¶
GetIPInfoFromIP is a helper function to call IPInfoMap.GetIPInfo using a net.IP. It uses special country codes to indicate errors:
- "XL": IP is not global ("L" is for "Local").
- "XD": database error looking up the country code ("D" is for "DB").
- "ZZ": lookup returned an empty country code (same as the Unicode unknown location).
type MMDBIPInfoMap ¶
type MMDBIPInfoMap struct {
// contains filtered or unexported fields
}
MMDBIpInfoMap is an ipinfo.IPInfoMap that uses MMDB files to lookup IP information.
func NewMMDBIPInfoMap ¶
func NewMMDBIPInfoMap(countryDBPath string, asnDBPath string) (*MMDBIPInfoMap, error)
NewMMDBIPInfoMap creates an ipinfo.IPInfoMap that uses the MMDB at countryDBPath to lookup IP Country information and the MMDB at asnDBPath to lookup IP ASN information. Either may be "", in which case you won't get the corresponding information in the IPInfo.
func (*MMDBIPInfoMap) Close ¶
func (ip2info *MMDBIPInfoMap) Close() error