aboutsummaryrefslogtreecommitdiff
path: root/src/feature/relay/dns.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2021-05-06 09:46:02 -0400
committerDavid Goulet <dgoulet@torproject.org>2021-05-12 11:58:25 -0400
commit423910e01bce71d58ad909fd92a45ac4eccb54e5 (patch)
treef4c6ab8aa8dbd363d2c5c0f6209491029c1ac339 /src/feature/relay/dns.c
parent897344fddc1ea5ba6dc0db814a703932b05560f4 (diff)
downloadtor-423910e01bce71d58ad909fd92a45ac4eccb54e5.tar.gz
tor-423910e01bce71d58ad909fd92a45ac4eccb54e5.zip
dns: Gather DNS request statistics
We now keep track of all errors and total number of request seen. This is so we can expose those values to the MetricsPort to help Exit operators monitor the DNS requests and failures. Related to #40367. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/relay/dns.c')
-rw-r--r--src/feature/relay/dns.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/feature/relay/dns.c b/src/feature/relay/dns.c
index 54c1de8903..c6e0439338 100644
--- a/src/feature/relay/dns.c
+++ b/src/feature/relay/dns.c
@@ -1650,6 +1650,10 @@ evdns_callback(int result, char type, int count, int ttl, void *addresses,
dns_found_answer(string_address, orig_query_type,
result, &addr, hostname, ttl);
+ /* The result can be changed within this function thus why we note the result
+ * at the end. */
+ rep_hist_note_dns_error(type, result);
+
tor_free(arg_);
}
@@ -1668,6 +1672,9 @@ launch_one_resolve(const char *address, uint8_t query_type,
addr[0] = (char) query_type;
memcpy(addr+1, address, addr_len + 1);
+ /* Note the query for our statistics. */
+ rep_hist_note_dns_request(query_type);
+
switch (query_type) {
case DNS_IPv4_A:
req = evdns_base_resolve_ipv4(the_evdns_base,