Documentation
¶
Overview ¶
These functions relate to figuring out the physical location of a particular player. The current granularity is limited to the country.
This functionlity depends on the IP-to-Country Lite CSV list downloaded from: https://db-ip.com/db/download/ip-to-country-lite. Any list will work really, but each record is expected to be in the following format:
x.x.x.x,y.y.y.y,zz
Where x.x.x.x is the first IP in a range, y.y.y.y is the last IP in a range and zz is the Alpha-2 ISO 3166 country code.
Note: these are not CIDR ranges and not even expected to be within the appropriate byte-boundaries for them. Converting these into actual CIDR ranges will in many cases result in a single record resolving to multiple CIDR ranges and possibly include some unintended top-end space. Just keep them as literal ranges of addresses.
Example 63.254.184.0 to 64.4.0.1 overlaps two different class As and various byte boundaries. This range would resolve to:
[ 63.254.184.0/21, 63.254.192.0/18, 63.255.0.0/16, 64.0.0.0/14, 64.4.0.0/31, ]
Not only is this a mega-bitch to caculate it'll result in 4 extra lookups to match an IP. Don't even get me started on doing this for IPv6 🤮
Index ¶
Constants ¶
const ( CmdBad = iota CmdNoOp CmdMove )
const (
GZipMagic = 35615 // 0x1f 0x8b
)
Variables ¶
This section is empty.
Functions ¶
func ParseInfoString ¶
Parse and info string (in the format of: "\key1\val1\key2\val2\key3\val3\" into a key/value map)
Types ¶
type GeoIP ¶ added in v1.0.303
A mapping of an IP range to a particular country. We can't use a *net.IPNet because first and last addresses aren't necessarily in the same CIDR range.
Supports IPv4 and IPv6
type GeoIPList ¶ added in v1.0.303
type GeoIPList []GeoIP
Make the list a type for use as a func receiver.
func LoadGeoIPData ¶ added in v1.0.303
Create the list of GeoIPs from raw bytes. Also determines if the data is compressed and handles that situation transparently. Only Gzip compression is supported.
func LoadGeoIPFile ¶ added in v1.0.303
Read each line of the ip-to-country database file into memory. This file should be in the format: