geoip - A Tcl extension for geographic or organisational lookup of
IP addresses and hostnames.
geoip open [-type TYPE ] [-flags FLAG ]
geoip open [-file PATH ] [-flags FLAG ]
geoip [COMMAND]
geoip [QUERY] arg1
This Tcl extension encapsulates most of GeoIP C API functions into
tcl commands.
open takes either a file path and a set of flags, or a type and a
set of flags. Supported types and flags are described below.
- TYPE
- Looks under the standard installation share directory, eg
/usr/local/share/GeoIP/ for a GeoIP database according to type.
- PATH
- Absolute/relative path to GeoIP database.
- FLAG
- Flags seperated by ':', eg memory_cache:memory_check
Individual singular commands can be one of:
- close
- Close the currently open database.
- db_info
- Get information about the current database.
- db_edition
- Returns edition of opened database.
- db_avail
- Test the availability of databases in your system in known locations. e.g
db_avail country_edition
Commands that query the database. All commands return N/A if a
result cannot be found. If none already open, a command will attempt to open
a suitable database. country commands will open a country_edition database.
region commands will open a region_edition_rev1 one. name commands will open
an org_edition one, and the record_edition will open a city_edition_rev1
database. The commands are:
- country_code_by_addr
- Takes an IP address and returns the ISO-3166-1 Alpha-2 code of the
country.
- country_code3_by_addr
- Takes an IP address and returns the ISO-3166-1 Alpha-3 code the
country.
- country_code_by_name
- Takes a hostname and returns the ISO-3166-1 Alpha-2 code the country.
- country_code3_by_name
- Takes a hostname and returns the ISO-3166-1 Alpha-3 code the country.
- country_name_by_addr
- Takes an IP address and returns the country name.
- country_name_by_name
- Takes a hostname and returns the country name.
- name_by_addr
- Takes an IP address and returns the organisation name (or ISP/ASnum
according to the opened database)
- name_by_name
- Takes a hostname and returns the organisation name.
- region_by_addr
- Takes an IP address and returns these region attributes as in an
associative array: country, region
- region_by_name
- Takes a hostname and returns the region attributes.
- record_by_addr
- Takes an IP address and returns these record attributes as in an
associative array: code, code3, region, country, city, postcode, latitude,
longitude, dma(dma code), and area (area code)
- record_by_name
- Takes a hostname and returns the record attributes.
Relevant types of databases are: country_edition, org_edition,
isp_edition, city_edition_rev1, region_edition_rev1, geoip_asnum_edition.
"open -type" will accept their unambiguous abbreviations.
Valid flags are: standard, memory_cache, check_cache,
index_cache.
- ./share/GeoIP.dat
- GeoIP country_edition database.
- ./share/GeoIPOrg.dat
- GeoIP org_edition database.
- ./share/GeoIPCity.dat
- GeoIP region_city_rev1 database.
- ./share/GeoIPRegion.dat
- GeoIP region_edition_rev1 database.
- ./share/GeoIPASNum.dat
- GeoIP asnum_edition database.
Djihed Afifi <djihed@gmail.com>.
GeoIP C API documentation <www.maxmind.com>