]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add documentation for geoiplookup and GeoIPQueryAttribute
authorBozhan Liang <lbz@rivensbane.com>
Sat, 14 Dec 2024 02:57:43 +0000 (10:57 +0800)
committerJames <lbz@rivensbane.com>
Thu, 23 Jan 2025 22:13:10 +0000 (11:13 +1300)
Closes #8597

docs/lua-records/functions.rst

index c71b86379209c871d490711d22f7552ae606339c..45a63a1c258b4d17e10fe0c15578e4108f7c7c63 100644 (file)
@@ -480,6 +480,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)