Documentation
¶
Overview ¶
Package ip2x reads IP2Location binary databases.
Index ¶
- Variables
- type DB
- func (db *DB) EachField(fn func(DBField) bool)
- func (db *DB) Has(f DBField) bool
- func (db *DB) HasIPv4() bool
- func (db *DB) HasIPv6() bool
- func (db *DB) Info() (DBProduct, DBType)
- func (db *DB) Lookup(a netip.Addr) (r Record, err error)
- func (db *DB) LookupString(ip string) (r Record, err error)
- func (db *DB) String() string
- func (db *DB) Version() string
- type DBField
- type DBProduct
- type DBType
- type Record
- func (r Record) FormatString(color, multiline bool) string
- func (r Record) Get(f DBField) any
- func (r Record) GetFloat32(f DBField) (float32, bool)
- func (r Record) GetString(f DBField) (string, bool)
- func (r Record) IsValid() bool
- func (r Record) MarshalJSON() ([]byte, error)
- func (r Record) String() string
Constants ¶
This section is empty.
Variables ¶
var ( RecordStringColor = false RecordStringMultiline = false )
Default options for Record.String.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB reads an IP2Location binary database.
func (*DB) Lookup ¶
Lookup looks up a in db. If a is not found, an empty record and nil error is returned. If an i/o error occurs, an empty record and non-nil error is returned.
func (*DB) LookupString ¶
LookupString parses and looks up a in db. If a parse error occurs, an empty record and nil error is returned. To catch parse errors, parse it separately using net/netip.ParseAddr, and pass it to DB.Lookup.
type DBField ¶
type DBField int
DBField represents a database column.
const AS DBField = 3
Autonomous system number (ASN).
const ASN DBField = 4
Autonomous system (AS) name.
const AddressType DBField = 1
IP address types as defined in Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6).
- (A) Anycast - One to the closest
- (U) Unicast - One to one
- (M) Multicast - One to multiple
- (B) Broadcast - One to all
const AreaCode DBField = 2
A varying length number assigned to geographic areas for call between cities.
const Category DBField = 5
The domain category is based on IAB Tech Lab Content Taxonomy.
These categories are comprised of Tier-1 and Tier-2 (if available) level categories widely used in services like advertising, Internet security and filtering appliances.
const City DBField = 6
City name.
const CountryCode DBField = 7
Two-character country code based on ISO 3166.
const CountryName DBField = 8
Country name based on ISO 3166.
const Domain DBField = 9
Internet domain name associated with IP address range.
const Elevation DBField = 10
Average height of city above sea level in meters (m).
const IDDCode DBField = 11
The IDD prefix to call the city from another country.
const ISP DBField = 12
Internet Service Provider or company's name.
const LastSeen DBField = 13
Proxy last seen in days.
const Latitude DBField = 14
City latitude. Defaults to capital city latitude if city is unknown.
const Longitude DBField = 15
City longitude. Defaults to capital city longitude if city is unknown.
const MCC DBField = 16
Mobile Country Codes (MCC) as defined in ITU E.212 for use in identifying mobile stations in wireless telephone networks, particularly GSM and UMTS networks.
const MNC DBField = 17
Mobile Network Code (MNC) is used in combination with a Mobile Country Code (MCC) to uniquely identify a mobile phone operator or carrier.
const MobileBrand DBField = 18
Commercial brand associated with the mobile carrier.
const NetSpeed DBField = 19
Internet Connection Type
- (DIAL) dial up
- (DSL) broadband/cable/fiber/mobile
- (COMP) company/T1
const Provider DBField = 20
Name of VPN provider if available.
const ProxyType DBField = 21
Type of proxy.
- (VPN) Anonymizing VPN services. These services offer users a publicly accessible VPN for the purpose of hiding their IP address. Anonymity: High.
- (TOR) Tor Exit Nodes. The Tor Project is an open network used by those who wish to maintain anonymity. Anonymity: High.
- (DCH) Hosting Provider, Data Center or Content Delivery Network. Since hosting providers and data centers can serve to provide anonymity, the Anonymous IP database flags IP addresses associated with them. Anonymity: Low.
- (PUB) Public Proxies. These are services which make connection requests on a user's behalf. Proxy server software can be configured by the administrator to listen on some specified port. These differ from VPNs in that the proxies usually have limited functions compare to VPNs. Anonymity: High.
- (WEB) Web Proxies. These are web services which make web requests on a user's behalf. These differ from VPNs or Public Proxies in that they are simple web-based proxies rather than operating at the IP address and other ports level. Anonymity: High.
- (SES) Search Engine Robots. These are services which perform crawling or scraping to a website, such as, the search engine spider or bots engine. Anonymity: Low.
- (RES) Residential proxies. These services offer users proxy connections through residential ISP with or without consents of peers to share their idle resources. Only available with PX10 & PX11. Anonymity: Medium.
const Region DBField = 22
Region or state name.
const Threat DBField = 23
Security threat reported.
- (SPAM) Email and forum spammers
- (SCANNER) Network security scanners
- (BOTNET) Malware infected devices
const Timezone DBField = 24
UTC time zone (with DST supported).
const UsageType DBField = 25
Usage type classification of ISP or company.
- (COM) Commercial
- (ORG) Organization
- (GOV) Government
- (MIL) Military
- (EDU) University/College/School
- (LIB) Library
- (CDN) Content Delivery Network
- (ISP) Fixed Line ISP
- (MOB) Mobile ISP
- (DCH) Data Center/Web Hosting/Transit
- (SES) Search Engine Spider
- (RSV) Reserved
const WeatherStationCode DBField = 26
The special code to identify the nearest weather observation station.
const WeatherStationName DBField = 27
The name of the nearest weather observation station.
const Zipcode DBField = 28
ZIP code or Postal code.
type DBProduct ¶
type DBProduct uint8
DBProduct represents an IP2Location database product.
const IP2Location DBProduct = 1
IP2Location™ IP Address Geolocation Database provides a solution to deduce the geolocation of a device connected to the Internet and to determine the approximate geographic location of an IP address along with some other useful information like country, region or state, city, latitude and longitude, ZIP/Postal code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type and advertising category.
const IP2Proxy DBProduct = 2
IP2Proxy™ Proxy Detection Database contains IP addresses which are used as VPN anonymizer, open proxies, web proxies and Tor exits, data center, web hosting (DCH) range, search engine robots (SES) and residential proxies (RES).
func (DBProduct) FormatProduct ¶
FormatProduct returns the full product name of t.
func (DBProduct) FormatType ¶
FormatType prepends the product prefix to t.
func (DBProduct) SupportsType ¶
SupportsType returns true if p supports variant t.
type DBType ¶
type DBType uint8
DBType represents an IP2Location database variant. Each database type contains different sets of columns.
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record points to a database row.
func (Record) FormatString ¶
FormatString gets and formats all fields in the record as a human-readable string. Note that this is highly inefficient.
func (Record) Get ¶
Get gets f as the default type. If an error occurs or the field is not present, nil is returned. This is slightly less efficient than the more specific getters.
func (Record) GetFloat32 ¶
GetFloat32 gets f as a float32, if possible.
func (Record) MarshalJSON ¶
MarshalJSON encodes the record as JSON.