Skip to content

Commit

Permalink
Add documentation for geoiplookup and GeoIPQueryAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
BozhanL committed Dec 14, 2024
1 parent 0b45ac7 commit 84a07c7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/lua-records/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,35 @@ Reverse DNS functions
Helper functions
~~~~~~~~~~~~~~~~

.. function:: geoiplookup(address, attr)

Retrieve specific attributes related to an IP address.

:param string address: The IP address to lookup.
:param int attr: The attribute identifier for the lookup.

You can use the following constants as the attribute:

- `GeoIPQueryAttribute.ASn`
- `GeoIPQueryAttribute.City`
- `GeoIPQueryAttribute.Continent`
- `GeoIPQueryAttribute.Country`
- `GeoIPQueryAttribute.Country2`
- `GeoIPQueryAttribute.Name`
- `GeoIPQueryAttribute.Region`
- `GeoIPQueryAttribute.Location`

Example::

asn.example.com IN LUA TXT "geoiplookup(bestwho:toString(), GeoIPQueryAttribute.ASn)" ; 1
city.example.com IN LUA TXT "geoiplookup(bestwho:toString(), GeoIPQueryAttribute.City)" ; auckland
continent.example.com IN LUA TXT "geoiplookup(bestwho:toString(), GeoIPQueryAttribute.Continent)" ; oc
country.example.com IN LUA TXT "geoiplookup(bestwho:toString(), GeoIPQueryAttribute.Country)" ; nz
country2.example.com IN LUA TXT "geoiplookup(bestwho:toString(), GeoIPQueryAttribute.Country2)" ; nz
name.example.com IN LUA TXT "geoiplookup(bestwho:toString(), GeoIPQueryAttribute.Name)" ; lvlt-1
region.example.com IN LUA TXT "geoiplookup(bestwho:toString(), GeoIPQueryAttribute.Region)" ; auk
location.example.com IN LUA TXT "geoiplookup(bestwho:toString(), GeoIPQueryAttribute.Location)" ; -36.000000 174.000000

.. function:: asnum(number)
asnum(numbers)

Expand Down

0 comments on commit 84a07c7

Please sign in to comment.