Comparison

net/dns.lua @ 8901:eae606b9266c

net.dns: Syntesize type names for the full range Otherwise unknown records are identified as A records. This also fixes various tracebacks unearthed by previous commits and mis-identified records. Related to #1056 #976 #819
author Kim Alvefur <zash@zash.se>
date Sat, 09 Jun 2018 15:34:00 +0200
parent 8900:fcf42bd7d067
child 8902:ac21f13798ae
child 8907:b7b960d30eef
comparison
equal deleted inserted replaced
8900:fcf42bd7d067 8901:eae606b9266c
84 local function highbyte(i) -- - - - - - - - - - - - - - - - - - - highbyte 84 local function highbyte(i) -- - - - - - - - - - - - - - - - - - - highbyte
85 return (i-(i%0x100))/0x100; 85 return (i-(i%0x100))/0x100;
86 end 86 end
87 87
88 88
89 local function augment (t) -- - - - - - - - - - - - - - - - - - - - augment 89 local function augment (t, prefix) -- - - - - - - - - - - - - - - - - augment
90 local a = {}; 90 local a = {};
91 for i,s in pairs(t) do 91 for i = 1, 0xffff do
92 local s = t[i] or ("%s%d"):format(prefix, i);
92 a[i] = s; 93 a[i] = s;
93 a[s] = s; 94 a[s] = s;
94 a[string.lower(s)] = s; 95 a[string.lower(s)] = s;
95 end 96 end
96 return a; 97 return a;
117 118
118 119
119 dns.classes = { 'IN', 'CS', 'CH', 'HS', [255] = '*' }; 120 dns.classes = { 'IN', 'CS', 'CH', 'HS', [255] = '*' };
120 121
121 122
122 dns.type = augment (dns.types); 123 dns.type = augment (dns.types, "TYPE");
123 dns.class = augment (dns.classes); 124 dns.class = augment (dns.classes, "CLASS");
124 dns.typecode = encode (dns.types); 125 dns.typecode = encode (dns.types);
125 dns.classcode = encode (dns.classes); 126 dns.classcode = encode (dns.classes);
126 127
127 128
128 129