Software /
code /
prosody
Comparison
net/dns.lua @ 8909:dbb5ec6885fe
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 10 Jun 2018 17:56:38 +0200 |
parent | 8903:c5d5dfaa8d38 |
parent | 8908:144666d0ad2f |
child | 9952:6402bc76f51a |
comparison
equal
deleted
inserted
replaced
8906:f15e35458ecc | 8909:dbb5ec6885fe |
---|---|
88 end | 88 end |
89 | 89 |
90 | 90 |
91 local function augment (t, prefix) -- - - - - - - - - - - - - - - - - augment | 91 local function augment (t, prefix) -- - - - - - - - - - - - - - - - - augment |
92 local a = {}; | 92 local a = {}; |
93 for i = 1, 0xffff do | 93 for i,s in pairs(t) do |
94 local s = t[i] or ("%s%d"):format(prefix, i); | |
95 a[i] = s; | 94 a[i] = s; |
96 a[s] = s; | 95 a[s] = s; |
97 a[string.lower(s)] = s; | 96 a[string.lower(s)] = s; |
98 end | 97 end |
98 setmetatable(a, { | |
99 __index = function (_, i) | |
100 if type(i) == "number" then | |
101 return ("%s%d"):format(prefix, i); | |
102 elseif type(i) == "string" then | |
103 return i:upper(); | |
104 end | |
105 end; | |
106 }) | |
99 return a; | 107 return a; |
100 end | 108 end |
101 | 109 |
102 | 110 |
103 local function encode (t) -- - - - - - - - - - - - - - - - - - - - - encode | 111 local function encode (t) -- - - - - - - - - - - - - - - - - - - - - encode |