From fc3c650e8dc62c3fdde8e2cc4eda62ed4a37c532 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 31 Mar 2021 13:30:53 +0100 Subject: [PATCH] Add support for per-DNSBL timeouts. This should fix the issue of some DNSBLs being slower than others. --- docs/conf/providers/torexit.conf.example | 1 + include/modules/dns.h | 4 ++-- src/modules/m_dnsbl.cpp | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/conf/providers/torexit.conf.example b/docs/conf/providers/torexit.conf.example index e9e62c43a..abc35c696 100644 --- a/docs/conf/providers/torexit.conf.example +++ b/docs/conf/providers/torexit.conf.example @@ -6,6 +6,7 @@ domain="torexit.dan.me.uk" type="record" records="100" + timeout="10s" action="zline" duration="7d" reason="Tor exit nodes are not allowed on this network. See https://metrics.torproject.org/rs.html#search/%ip% for more information."> diff --git a/include/modules/dns.h b/include/modules/dns.h index 5b1c426cd..bce842bd8 100644 --- a/include/modules/dns.h +++ b/include/modules/dns.h @@ -166,8 +166,8 @@ namespace DNS /* Creator of this request */ Module* const creator; - Request(Manager* mgr, Module* mod, const std::string& addr, QueryType qt, bool usecache = true) - : Timer(ServerInstance->Config->ConfValue("dns")->getDuration("timeout", 5, 1)) + Request(Manager* mgr, Module* mod, const std::string& addr, QueryType qt, bool usecache = true, unsigned int timeout = 0) + : Timer(timeout ? timeout : ServerInstance->Config->ConfValue("dns")->getDuration("timeout", 5, 1)) , manager(mgr) , question(addr, qt) , use_cache(usecache) diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 57a780ff2..dc43dda3f 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -42,12 +42,14 @@ class DNSBLConfEntry : public refcountbase EnumType type; unsigned long duration; unsigned int bitmask; + unsigned int timeout; unsigned char records[256]; unsigned long stats_hits, stats_misses, stats_errors; DNSBLConfEntry() : type(A_BITMASK) , duration(86400) , bitmask(0) + , timeout(0) , stats_hits(0) , stats_misses(0) , stats_errors(0) @@ -69,7 +71,7 @@ class DNSBLResolver : public DNS::Request public: DNSBLResolver(DNS::Manager *mgr, Module *me, LocalStringExt& match, LocalIntExt& ctr, const std::string &hostname, LocalUser* u, reference conf) - : DNS::Request(mgr, me, hostname, DNS::QUERY_A, true) + : DNS::Request(mgr, me, hostname, DNS::QUERY_A, true, conf->timeout) , theirsa(u->client_sa) , theiruid(u->uuid) , nameExt(match) @@ -343,6 +345,7 @@ class ModuleDNSBL : public Module, public Stats::EventListener e->host = tag->getString("host"); e->reason = tag->getString("reason", "Your IP has been blacklisted.", 1); e->domain = tag->getString("domain"); + e->timeout = tag->getDuration("timeout", 0); if (stdalgo::string::equalsci(tag->getString("type"), "bitmask")) { -- 2.39.2