-local hints = { -- - - - - - - - - - - - - - - - - - - - - - - - - - - hints
- qr = { [0]='query', 'response' },
- opcode = { [0]='query', 'inverse query', 'server status request' },
- aa = { [0]='non-authoritative', 'authoritative' },
- tc = { [0]='complete', 'truncated' },
- rd = { [0]='recursion not desired', 'recursion desired' },
- ra = { [0]='recursion not available', 'recursion available' },
- z = { [0]='(reserved)' },
- rcode = { [0]='no error', 'format error', 'server failure', 'name error',
- 'not implemented' },
-
- type = dns.type,
- class = dns.class, }
-
-
-local function hint (p, s) -- - - - - - - - - - - - - - - - - - - - - - hint
- return (hints[s] and hints[s][p[s]]) or '' end
-
-
-function resolver.print (response) -- - - - - - - - - - - - - resolver.print
-
- for s,s in pairs { 'id', 'qr', 'opcode', 'aa', 'tc', 'rd', 'ra', 'z',
- 'rcode', 'qdcount', 'ancount', 'nscount', 'arcount' } do
- print ( string.format ('%-30s', 'header.'..s),
- response.header[s], hint (response.header, s) )
- end
-
- for i,question in ipairs (response.question) do
- print (string.format ('question[%i].name ', i), question.name)
- print (string.format ('question[%i].type ', i), question.type)
- print (string.format ('question[%i].class ', i), question.class)
- end
-
- local common = { name=1, type=1, class=1, ttl=1, rdlength=1, rdata=1 }
- local tmp
- for s,s in pairs {'answer', 'authority', 'additional'} do
- for i,rr in pairs (response[s]) do
- for j,t in pairs { 'name', 'type', 'class', 'ttl', 'rdlength' } do
- tmp = string.format ('%s[%i].%s', s, i, t)
- print (string.format ('%-30s', tmp), rr[t], hint (rr, t))
- end
- for j,t in pairs (rr) do
- if not common[j] then
- tmp = string.format ('%s[%i].%s', s, i, j)
- print (string.format ('%-30s %s', tostring(tmp), tostring(t)))
- end end end end end
+ local common = { name=1, type=1, class=1, ttl=1, rdlength=1, rdata=1 };
+ local tmp;
+ for s,s in pairs({'answer', 'authority', 'additional'}) do
+ for i,rr in pairs(response[s]) do
+ for j,t in pairs({ 'name', 'type', 'class', 'ttl', 'rdlength' }) do
+ tmp = string.format('%s[%i].%s', s, i, t);
+ print(string.format('%-30s', tmp), rr[t], hint(rr, t));
+ end
+ for j,t in pairs(rr) do
+ if not common[j] then
+ tmp = string.format('%s[%i].%s', s, i, j);
+ print(string.format('%-30s %s', tostring(tmp), tostring(t)));
+ end
+ end
+ end
+ end
+end