geoip(3)

πŸ“¦ version 0.2, in ubuntu jammy

πŸ’– geoip β€” the Tcl glow-up for IP lookups πŸ’–

okay so bestie, welcome to geoip(3), manual section 3, straight out of Version 0.2 ✨ this is the Tcl extension that does geographic and organisational lookups of IP addresses and hostnames, and she is lowkey iconic.


✨ NAME ✨

geoip β€” a Tcl extension for geographic or organisational lookup of IP addresses and hostnames. that's it, that's the girl 🫢


🌸 SYNOPSIS 🌸

no cap, here's how you call her:

geoip open [-type TYPE ] [-flags FLAG ]
geoip open [-file PATH ] [-flags FLAG ]
geoip [COMMAND]
geoip [QUERY] arg1

πŸ¦‹ DESCRIPTION πŸ¦‹

this Tcl extension literally wraps up most of the GeoIP C API functions and turns them into Tcl commands. so you get to stay in your cozy Tcl era instead of going full C-mode. she ate πŸ’…


πŸŽ€ OPEN OPTIONS πŸŽ€

open takes either a file path plus a set of flags, or a type plus a set of flags. both paths are valid, pick your fighter. supported types and flags live below πŸ‘‡

  • TYPE β€” looks under the standard installation share directory, eg /usr/local/share/GeoIP/ for a GeoIP database according to type. it just knows where to look 🧚
  • PATH β€” absolute or relative path to the GeoIP database. you tell her exactly where it lives.
  • FLAG β€” flags seperated by ':', eg memory_cache:memory_check. yes, that spelling is the original's, we keep it fr fr πŸ™ˆ

πŸ‘‘ COMMAND πŸ‘‘

individual singular commands can be one of:

  • close β€” close the currently open database. bye bestie, gate closed πŸšͺ
  • 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. she's doing a vibe check on your databases ⭐

πŸ”₯ QUERY πŸ”₯

these are the commands that actually query the database. all commands return N/A if a result cannot be found β€” no drama, just a polite shrug.

also: if none is already open, a command will attempt to open a suitable database on its own. main character energy, she handles it 😌

  • 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.
  • 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.

🌈 TYPES 🌈

relevant types of databases are: country_edition, org_edition, isp_edition, city_edition_rev1, region_edition_rev1, geoip_asnum_edition.

and here's the slay part: open -type will accept their unambiguous abbreviations. so you don't have to type the whole thing, she gets the vibe πŸ’œ


πŸ’… FLAGS πŸ’…

valid flags are: standard, memory_cache, check_cache, index_cache.


πŸ“ FILES πŸ“

  • ./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.

πŸ’€ BUGS πŸ’€

please report to author. (not me, not the group chat β€” the author. go tell them directly bestie 😭)

🫢 AUTHOR 🫢

Djihed Afifi <djihed@gmail.com>.


πŸ‘€ SEE ALSO πŸ‘€

GeoIP C API documentation <www.maxmind.com> β€” go read the source material, iykyk.


and that's the whole page, periodt. this was geoip(3) from the Tcl extension fam, dated April 2007 β€” yes she's an elder but she still serves βœ¨πŸ’–πŸŽ€ mwah, go do your lookups πŸ¦‹

πŸ“¦ where this page comes from