]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/dns64: allow configuring by a table
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 10 Aug 2021 09:21:13 +0000 (11:21 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 19 Aug 2021 14:10:58 +0000 (16:10 +0200)
Backward compatible.  It will be useful when adding further features.
Also improve config error traces.

modules/dns64/dns64.lua

index a389b7837276b4af37d03f7b4e6435081f045075..7f84d82e70ad2b57af75daa201ac19121fd90295 100644 (file)
@@ -19,9 +19,14 @@ Missing parts of the RFC:
 ]]
 
 -- Config
-function M.config (confstr)
-       M.proxy = kres.str2ip(confstr or '64:ff9b::')
-       if M.proxy == nil then error('[dns64] "'..confstr..'" is not a valid address') end
+function M.config(conf)
+       if type(conf) ~= 'table' then
+               conf = { prefix = conf }
+       end
+       M.proxy = kres.str2ip(tostring(conf.prefix or '64:ff9b::'))
+       if M.proxy == nil or #M.proxy ~= 16 then
+               error(string.format('[dns64] %q is not a valid IPv6 address', conf.prefix), 2)
+       end
 end
 
 -- Layers