summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2021-03-31 13:30:53 +0100
committerSadie Powell <sadie@witchery.services>2021-03-31 13:41:55 +0100
commitfc3c650e8dc62c3fdde8e2cc4eda62ed4a37c532 (patch)
tree394756c4b9ec46fd8cf99027c010c0e763017cf3
parent952ee5cc603a5231348b8cfab18ee85a097f5394 (diff)
Add support for per-DNSBL timeouts.
This should fix the issue of some DNSBLs being slower than others.
-rw-r--r--docs/conf/providers/torexit.conf.example1
-rw-r--r--include/modules/dns.h4
-rw-r--r--src/modules/m_dnsbl.cpp5
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<DNSBLConfEntry> 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"))
{