Mercurial > prosody-hg
comparison util/dns.lua @ 12236:d0dfd48806f9
util.dns: Move DNS parameters details into util.dnsregistry
Goal is to regenerate this file from the IANA registry using a tool.
Having it in a separate file will reduce vcs noise in util.dns
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 04 Oct 2020 19:23:16 +0200 |
| parents | b3773b1b90a1 |
| children | 578ce0415398 |
comparison
equal
deleted
inserted
replaced
| 12235:c98527220564 | 12236:d0dfd48806f9 |
|---|---|
| 16 local s_match = string.match; | 16 local s_match = string.match; |
| 17 local s_gmatch = string.gmatch; | 17 local s_gmatch = string.gmatch; |
| 18 | 18 |
| 19 local have_net, net_util = pcall(require, "util.net"); | 19 local have_net, net_util = pcall(require, "util.net"); |
| 20 | 20 |
| 21 local iana_data = require "util.dnsregistry"; | |
| 21 if have_net and not net_util.ntop then -- Added in Prosody 0.11 | 22 if have_net and not net_util.ntop then -- Added in Prosody 0.11 |
| 22 have_net = false; | 23 have_net = false; |
| 23 end | 24 end |
| 24 | 25 |
| 25 local chartohex = {}; | 26 local chartohex = {}; |
| 29 end | 30 end |
| 30 | 31 |
| 31 local function tohex(s) | 32 local function tohex(s) |
| 32 return (s_gsub(s, ".", chartohex)); | 33 return (s_gsub(s, ".", chartohex)); |
| 33 end | 34 end |
| 34 | |
| 35 -- Converted from | |
| 36 -- http://www.iana.org/assignments/dns-parameters | |
| 37 -- 2020-06-25 | |
| 38 | |
| 39 local classes = { | |
| 40 IN = 1; "IN"; | |
| 41 nil; | |
| 42 CH = 3; "CH"; | |
| 43 HS = 4; "HS"; | |
| 44 }; | |
| 45 | |
| 46 local types = { | |
| 47 "A";"NS";"MD";"MF";"CNAME";"SOA";"MB";"MG";"MR";"NULL";"WKS";"PTR";"HINFO"; | |
| 48 "MINFO";"MX";"TXT";"RP";"AFSDB";"X25";"ISDN";"RT";"NSAP";"NSAP-PTR";"SIG"; | |
| 49 "KEY";"PX";"GPOS";"AAAA";"LOC";"NXT";"EID";"NIMLOC";"SRV";"ATMA";"NAPTR"; | |
| 50 "KX";"CERT";"A6";"DNAME";"SINK";"OPT";"APL";"DS";"SSHFP";"IPSECKEY";"RRSIG"; | |
| 51 "NSEC";"DNSKEY";"DHCID";"NSEC3";"NSEC3PARAM";"TLSA";"SMIMEA";[55]="HIP"; | |
| 52 [56]="NINFO";[57]="RKEY";[58]="TALINK";[59]="CDS";[60]="CDNSKEY";[61]="OPENPGPKEY"; | |
| 53 [62]="CSYNC";[63]="ZONEMD";[99]="SPF";[100]="UINFO";[101]="UID";[102]="GID"; | |
| 54 [103]="UNSPEC";[104]="NID";[105]="L32";[106]="L64";[107]="LP";[108]="EUI48"; | |
| 55 [109]="EUI64";["CSYNC"]=62;["TXT"]=16;["NAPTR"]=35;["A6"]=38;["RP"]=17; | |
| 56 ["TALINK"]=58;["NXT"]=30;["MR"]=9;["UINFO"]=100;["X25"]=19;["TKEY"]=249; | |
| 57 ["CERT"]=37;["SMIMEA"]=53;[252]="AXFR";[253]="MAILB";["CDS"]=59;[32769]="DLV"; | |
| 58 ["RT"]=21;["WKS"]=11;[249]="TKEY";["LP"]=107;[250]="TSIG";["SSHFP"]=44;["DS"]=43; | |
| 59 ["ISDN"]=20;["ATMA"]=34;["NS"]=2;[257]="CAA";["PX"]=26;["MX"]=15;["TSIG"]=250; | |
| 60 ["EID"]=31;["TLSA"]=52;["GID"]=102;["KX"]=36;["SPF"]=99;["DOA"]=259;["GPOS"]=27; | |
| 61 ["IPSECKEY"]=45;["NIMLOC"]=32;["RRSIG"]=46;["UID"]=101;["DNAME"]=39;["NSAP"]=22; | |
| 62 ["DNSKEY"]=48;["SINK"]=40;["DHCID"]=49;[32768]="TA";["NSAP-PTR"]=23;["AAAA"]=28; | |
| 63 ["PTR"]=12;["MINFO"]=14;["TA"]=32768;["EUI64"]=109;[260]="AMTRELAY"; | |
| 64 ["AMTRELAY"]=260;["CDNSKEY"]=60;[259]="DOA";["LOC"]=29;[258]="AVC";["AVC"]=258; | |
| 65 ["CAA"]=257;["MB"]=7;["*"]=255;[256]="URI";["URI"]=256;["SRV"]=33;["EUI48"]=108; | |
| 66 [255]="*";[254]="MAILA";["MAILA"]=254;["MAILB"]=253;["CNAME"]=5;[251]="IXFR"; | |
| 67 ["APL"]=42;["OPENPGPKEY"]=61;["MD"]=3;["NINFO"]=56;["ZONEMD"]=63;["RKEY"]=57; | |
| 68 ["L32"]=105;["NID"]=104;["HIP"]=55;["NSEC"]=47;["DLV"]=32769;["UNSPEC"]=103; | |
| 69 ["NSEC3PARAM"]=51;["MF"]=4;["MG"]=8;["AFSDB"]=18;["A"]=1;["SIG"]=24;["NSEC3"]=50; | |
| 70 ["HINFO"]=13;["IXFR"]=251;["NULL"]=10;["AXFR"]=252;["KEY"]=25;["OPT"]=41; | |
| 71 ["SOA"]=6;["L64"]=106; | |
| 72 } | |
| 73 | |
| 74 local errors = { | |
| 75 NoError = "No Error"; [0] = "NoError"; | |
| 76 FormErr = "Format Error"; "FormErr"; | |
| 77 ServFail = "Server Failure"; "ServFail"; | |
| 78 NXDomain = "Non-Existent Domain"; "NXDomain"; | |
| 79 NotImp = "Not Implemented"; "NotImp"; | |
| 80 Refused = "Query Refused"; "Refused"; | |
| 81 YXDomain = "Name Exists when it should not"; "YXDomain"; | |
| 82 YXRRSet = "RR Set Exists when it should not"; "YXRRSet"; | |
| 83 NXRRSet = "RR Set that should exist does not"; "NXRRSet"; | |
| 84 NotAuth = "Server Not Authoritative for zone"; "NotAuth"; | |
| 85 NotZone = "Name not contained in zone"; "NotZone"; | |
| 86 }; | |
| 87 | 35 |
| 88 -- Simplified versions of Waqas DNS parsers | 36 -- Simplified versions of Waqas DNS parsers |
| 89 -- Only the per RR parsers are needed and only feed a single RR | 37 -- Only the per RR parsers are needed and only feed a single RR |
| 90 | 38 |
| 91 local parsers = {}; | 39 local parsers = {}; |
| 268 end | 216 end |
| 269 setmetatable(parsers, { __index = function() return fallback_parser end }); | 217 setmetatable(parsers, { __index = function() return fallback_parser end }); |
| 270 | 218 |
| 271 return { | 219 return { |
| 272 parsers = parsers; | 220 parsers = parsers; |
| 273 classes = classes; | 221 classes = iana_data.classes; |
| 274 types = types; | 222 types = iana_data.types; |
| 275 errors = errors; | 223 errors = iana_data.errors; |
| 276 params = params; | 224 params = params; |
| 277 }; | 225 }; |
