]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
support text conversion of unknown RR types
authorMarek Vavruša <mvavrusa@cloudflare.com>
Tue, 2 Jan 2018 23:03:22 +0000 (15:03 -0800)
committerPetr Špaček <petr.spacek@nic.cz>
Thu, 4 Jan 2018 10:04:41 +0000 (11:04 +0100)
daemon/lua/kres.lua
tests/config/basic_test.lua

index 205f10ba1ed36ffead1e5785ee9eff6c94d8ef56..8578b057b535fa7dfddff88824461f5639ca5562 100644 (file)
@@ -203,6 +203,15 @@ setmetatable(const_type, {
        end
 })
 
+-- Metatype for RR types to allow anonymous string types
+setmetatable(const_type_str, {
+       __index = function (t, k)
+               local v = rawget(t, k)
+               if v then return v end
+               return string.format('TYPE%d', k)
+       end
+})
+
 -- Metatype for sockaddr
 local addr_buf = ffi.new('char[16]')
 local sockaddr_t = ffi.typeof('struct sockaddr')
index b929bfe5dcd206cc68439819bbfd844a11475758..df4fff71089ebb9cffb0c7661c91b982e7a79150 100644 (file)
@@ -10,6 +10,7 @@ local function test_constants()
        -- Test inverset tables to convert constants to text
        same(kres.tostring.class[1], 'IN', 'text class constants work')
        same(kres.tostring.type[2], 'NS', 'text record type constants work')
+       same(kres.tostring.type[65535], 'TYPE65535', 'text record type undefined constants work')
        same(kres.tostring.section[0], 'ANSWER', 'text section constants work')
        same(kres.tostring.rcode[2], 'SERVFAIL', 'text rcode constants work')
        same(kres.tostring.opcode[5], 'UPDATE', 'text opcode constants work')