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() (p DBProduct, t 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) Format(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 uint
DBField represents a database column.
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
In DB25-26.
const AreaCode DBField = 2
A varying length number assigned to geographic areas for call between cities.
See https://www.ip2location.com/area-code-coverage.
In DB15-16, DB18, DB20-22, DB24-26.
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.
See https://www.ip2location.com/free/iab-categories.
In DB25-26.
const Domain DBField = 9
Internet domain name associated with IP address range.
In DB7-8, DB10, DB12, DB14, DB16, DB18-20, DB22-26, PX5-11.
const Elevation DBField = 11
Average height of city above sea level in meters (m).
In DB21-22, DB24-26.
const IDDCode DBField = 12
The IDD prefix to call the city from another country.
In DB15-16, DB18, DB20-22, DB24-26.
const ISP DBField = 13
Internet Service Provider or company's name.
In DB2, DB4, DB6-8, DB10, DB12, DB14, DB16, DB18-20, DB22-26, PX4-11.
const Latitude DBField = 15
City latitude. Defaults to capital city latitude if city is unknown.
In DB5-6, DB8-26.
const Longitude DBField = 16
City longitude. Defaults to capital city longitude if city is unknown.
In DB5-6, DB8-26.
const MCC DBField = 17
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.
In DB19-20, DB22-26.
const MNC DBField = 18
Mobile Network Code (MNC) is used in combination with a Mobile Country Code (MCC) to uniquely identify a mobile phone operator or carrier.
In DB19-20, DB22-26.
const MobileBrand DBField = 19
Commercial brand associated with the mobile carrier.
See https://www.ip2location.com/mobile-carrier-coverage.
In DB19-20, DB22-26.
const NetSpeed DBField = 20
Internet Connection Type
- (DIAL) dial up
- (DSL) broadband/cable/fiber/mobile
- (COMP) company/T1
In DB13-14, DB16-18, DB20, DB22, DB24-26.
const ProxyType DBField = 22
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.
In PX2-11.
const Threat DBField = 24
Security threat reported.
- (SPAM) Email and forum spammers
- (SCANNER) Network security scanners
- (BOTNET) Malware infected devices
In PX9-11.
const UsageType DBField = 26
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
In DB23-26, PX6-11.
const WeatherStationCode DBField = 27
The special code to identify the nearest weather observation station.
In DB17-18, DB20, DB22, DB24-26.
const WeatherStationName DBField = 28
The name of the nearest weather observation station.
In DB17-18, DB20, DB22, DB24-26.
const Zipcode DBField = 29
ZIP code or Postal code.
See https://www.ip2location.com/zip-code-coverage.
In DB9-12, DB14-16, DB18, DB20-22, DB24-26.
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. Up to DB26.
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). Up to PX11.
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) Format ¶ added in v0.3.0
Format 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.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
ip2x
Command ip2x queries an IP2Location binary database.
|
Command ip2x queries an IP2Location binary database. |
internal
|
|
codegen
Package codegen generates ip2x source code for IP2Location binary databases.
|
Package codegen generates ip2x source code for IP2Location binary databases. |
test
module
|