Software /
code /
prosody
Comparison
net/dns.lua @ 8907:b7b960d30eef
Backed out changeset eae606b9266c: Used a lot of memory
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 10 Jun 2018 17:37:06 +0200 |
parent | 8901:eae606b9266c |
child | 8908:144666d0ad2f |
comparison
equal
deleted
inserted
replaced
8905:65d1a80d3565 | 8907:b7b960d30eef |
---|---|
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, prefix) -- - - - - - - - - - - - - - - - - augment | 89 local function augment (t) -- - - - - - - - - - - - - - - - - - - - augment |
90 local a = {}; | 90 local a = {}; |
91 for i = 1, 0xffff do | 91 for i,s in pairs(t) do |
92 local s = t[i] or ("%s%d"):format(prefix, i); | |
93 a[i] = s; | 92 a[i] = s; |
94 a[s] = s; | 93 a[s] = s; |
95 a[string.lower(s)] = s; | 94 a[string.lower(s)] = s; |
96 end | 95 end |
97 return a; | 96 return a; |
118 | 117 |
119 | 118 |
120 dns.classes = { 'IN', 'CS', 'CH', 'HS', [255] = '*' }; | 119 dns.classes = { 'IN', 'CS', 'CH', 'HS', [255] = '*' }; |
121 | 120 |
122 | 121 |
123 dns.type = augment (dns.types, "TYPE"); | 122 dns.type = augment (dns.types); |
124 dns.class = augment (dns.classes, "CLASS"); | 123 dns.class = augment (dns.classes); |
125 dns.typecode = encode (dns.types); | 124 dns.typecode = encode (dns.types); |
126 dns.classcode = encode (dns.classes); | 125 dns.classcode = encode (dns.classes); |
127 | 126 |
128 | 127 |
129 | 128 |