Software / code / prosody
Comparison
util/dns.lua @ 12288:08a933450922
util.dns: Replace base16 implementation with util.hex
Less code!
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 15 Feb 2022 13:03:02 +0100 |
| parent | 12241:dd15f42f6312 |
| child | 12289:3a655adf1d0d |
comparison
equal
deleted
inserted
replaced
| 12287:5cd075ed4fd3 | 12288:08a933450922 |
|---|---|
| 7 local setmetatable = setmetatable; | 7 local setmetatable = setmetatable; |
| 8 local table = table; | 8 local table = table; |
| 9 local t_concat = table.concat; | 9 local t_concat = table.concat; |
| 10 local t_insert = table.insert; | 10 local t_insert = table.insert; |
| 11 local s_byte = string.byte; | 11 local s_byte = string.byte; |
| 12 local s_char = string.char; | |
| 13 local s_format = string.format; | 12 local s_format = string.format; |
| 14 local s_gsub = string.gsub; | 13 local s_gsub = string.gsub; |
| 15 local s_sub = string.sub; | 14 local s_sub = string.sub; |
| 16 local s_match = string.match; | 15 local s_match = string.match; |
| 17 local s_gmatch = string.gmatch; | 16 local s_gmatch = string.gmatch; |
| 21 local iana_data = require "util.dnsregistry"; | 20 local iana_data = require "util.dnsregistry"; |
| 22 if have_net and not net_util.ntop then -- Added in Prosody 0.11 | 21 if have_net and not net_util.ntop then -- Added in Prosody 0.11 |
| 23 have_net = false; | 22 have_net = false; |
| 24 end | 23 end |
| 25 | 24 |
| 26 local chartohex = {}; | 25 local tohex = require "util.hex".to; |
| 27 | |
| 28 for c = 0, 255 do | |
| 29 chartohex[s_char(c)] = s_format("%02X", c); | |
| 30 end | |
| 31 | |
| 32 local function tohex(s) | |
| 33 return (s_gsub(s, ".", chartohex)); | |
| 34 end | |
| 35 | 26 |
| 36 -- Simplified versions of Waqas DNS parsers | 27 -- Simplified versions of Waqas DNS parsers |
| 37 -- Only the per RR parsers are needed and only feed a single RR | 28 -- Only the per RR parsers are needed and only feed a single RR |
| 38 | 29 |
| 39 local parsers = {}; | 30 local parsers = {}; |