]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Fix country()/countryCode() mixup in example Lua Record 13714/head
authorEdward Dore <5480052+spheron1@users.noreply.github.com>
Sun, 14 Jan 2024 11:22:29 +0000 (11:22 +0000)
committerGitHub <noreply@github.com>
Sun, 14 Jan 2024 11:22:29 +0000 (11:22 +0000)
The country() function returns true if the country code for the query source IP address matches the country code passed to the function.
The countryCode() function doesn't take any arguments and just returns the country code of the query source IP address.

For this example, we're checking if the country for the query source IP address is "US" and expecting a true/false response, so country() is the correct function to use.
Alternatively, this would be something like "if countryCode() == 'US' then return...".

docs/lua-records/index.rst

index 4028feb65c7a1ea5e55845a7b9ccfe1de227fda4..74367a21e83eed24bf820ced752b895b08aad772 100644 (file)
@@ -78,7 +78,7 @@ This will pick from the viable IP addresses the one deemed closest to the user.
 
 LUA records can also contain more complex code, for example::
 
-    www    IN    LUA    A    ";if countryCode('US') then return {'192.0.2.1','192.0.2.2','198.51.100.1'} else return '192.0.2.2' end"
+    www    IN    LUA    A    ";if country('US') then return {'192.0.2.1','192.0.2.2','198.51.100.1'} else return '192.0.2.2' end"
 
 As you can see you can return both single string value or array of strings.