local msg = '1 resolver.example. alpn=dot ipv4hint=192.0.2.1 ipv6hint=2001:db8::1' answer:put(qry.sname, 900, answer:qclass(), kres.type.SVCB, string.char(#msg) .. msg)
This part won't construct correct wire format for SVCB.
I think this example should work:
-- Parse RDATA, from presentation to wire-format. -- in: a string or table of strings, each a line describing RRTYPE+RDATA -- out: a table of RDATA strings in wire-format function parse_rdata(strs, nothing) local zonefile = require('zonefile') if nothing ~= nil then -- accidents like forgetting braces error('one string or table of strings is accepted', 2) end if type(strs) ~= 'table' then strs = { strs } end -- TODO: allow this case? local res = {} for _, line in ipairs(strs) do if type(line) ~= 'string' then error('one string or table of strings is accepted', 2) end local rrs = zonefile.string('. ' .. line) if #rrs == 0 then error('failed to parse line: ' .. line, 2) end for _, rr in ipairs(rrs) do table.insert(res, rr.rdata) end end return res end svcb_str = { 'SVCB 1 dns.quad9.net. alpn=dot port=853 ipv4hint=9.9.9.9,149.112.112.112 ipv6hint=2620:fe::fe', 'SVCB 2 dns.quad9.net. mandatory=key65380 alpn=h2 port=443 ipv4hint=9.9.9.9,149.112.112.112 ipv6hint=2620:fe::fe key65380="/dns-query{?dns}"', } policy.add( policy.suffix( policy.ANSWER({ [kres.type.SVCB] = { rdata=parse_rdata(svcb_str), ttl=300 } }, true), { todname('_dns.resolver.arpa') }))