Mercurial > prosody-hg
comparison net/unbound.lua @ 13981:350e16e5f9aa
net.unbound: Count number of DNS response records
In order to gather stats on how wide-spread various record types are,
and how many records per rrset are common.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 07 Oct 2025 23:50:12 +0200 |
| parents | 5abdcad8c2e0 |
| children | 41fa97090264 |
comparison
equal
deleted
inserted
replaced
| 13980:d8c001271669 | 13981:350e16e5f9aa |
|---|---|
| 117 | 117 |
| 118 local function measure(_qclass, _qtype) | 118 local function measure(_qclass, _qtype) |
| 119 return measure; | 119 return measure; |
| 120 end | 120 end |
| 121 | 121 |
| 122 local count = measure; | |
| 123 | |
| 122 local function lookup(callback, qname, qtype, qclass) | 124 local function lookup(callback, qname, qtype, qclass) |
| 123 if not unbound then initialize(); end | 125 if not unbound then initialize(); end |
| 124 qtype = qtype and s_upper(qtype) or "A"; | 126 qtype = qtype and s_upper(qtype) or "A"; |
| 125 qclass = qclass and s_upper(qclass) or "IN"; | 127 qclass = qclass and s_upper(qclass) or "IN"; |
| 126 local ntype, nclass = types[qtype], classes[qclass]; | 128 local ntype, nclass = types[qtype], classes[qclass]; |
| 130 local log_query = logger.init("unbound.query"..new_id()); | 132 local log_query = logger.init("unbound.query"..new_id()); |
| 131 local function callback_wrapper(a, err) | 133 local function callback_wrapper(a, err) |
| 132 m(); | 134 m(); |
| 133 waiting_queries[ret] = nil; | 135 waiting_queries[ret] = nil; |
| 134 if a then | 136 if a then |
| 137 count(qclass, qtype, #a); | |
| 135 prep_answer(a); | 138 prep_answer(a); |
| 136 log_query("debug", "Results for %s %s %s: %s (%s)", qname, qclass, qtype, a.rcode == 0 and (#a .. " items") or a.status, | 139 log_query("debug", "Results for %s %s %s: %s (%s)", qname, qclass, qtype, a.rcode == 0 and (#a .. " items") or a.status, |
| 137 a.secure and "Secure" or a.bogus or "Insecure"); -- Insecure as in unsigned | 140 a.secure and "Secure" or a.bogus or "Insecure"); -- Insecure as in unsigned |
| 138 else | 141 else |
| 139 log_query("error", "Results for %s %s %s: %s", qname, qclass, qtype, tostring(err)); | 142 log_query("error", "Results for %s %s %s: %s", qname, qclass, qtype, tostring(err)); |
| 228 settimeout = function () end; | 231 settimeout = function () end; |
| 229 closeall = function () end; | 232 closeall = function () end; |
| 230 }; | 233 }; |
| 231 } | 234 } |
| 232 | 235 |
| 233 _M.instrument = function(measure_) measure = measure_; end; | 236 _M.instrument = function(measure_, count_) measure, count = measure_, count_; end; |
| 234 | 237 |
| 235 function _M.resolver() return wrapper; end | 238 function _M.resolver() return wrapper; end |
| 236 | 239 |
| 237 return _M; | 240 return _M; |
