From: Vladimír Čunát Date: Tue, 10 Aug 2021 09:21:13 +0000 (+0200) Subject: modules/dns64: allow configuring by a table X-Git-Tag: v5.4.2~8^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=331347925ce1d9569e1bea1bcca552baa0a15a4d;p=thirdparty%2Fknot-resolver.git modules/dns64: allow configuring by a table Backward compatible. It will be useful when adding further features. Also improve config error traces. --- diff --git a/modules/dns64/dns64.lua b/modules/dns64/dns64.lua index a389b7837..7f84d82e7 100644 --- a/modules/dns64/dns64.lua +++ b/modules/dns64/dns64.lua @@ -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