]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add support for per-DNSBL timeouts.
authorSadie Powell <sadie@witchery.services>
Wed, 31 Mar 2021 12:30:53 +0000 (13:30 +0100)
committerSadie Powell <sadie@witchery.services>
Wed, 31 Mar 2021 12:41:55 +0000 (13:41 +0100)
This should fix the issue of some DNSBLs being slower than others.

docs/conf/providers/torexit.conf.example
include/modules/dns.h
src/modules/m_dnsbl.cpp

index e9e62c43a5d011bc7033fb6b4ac4c6a7f693869e..abc35c696887b8b99ba81d06bb3d43c4b202f825 100644 (file)
@@ -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.">
index 5b1c426cd5e6644af9af0f6f0a3ae438996473c2..bce842bd8821a769c22a907b91f683ed9fdf814d 100644 (file)
@@ -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)
index 57a780ff2d1685c53fa13154ee6f679bec48b934..dc43dda3f0c6f2045580a47ce77a51855693aa13 100644 (file)
@@ -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"))
                        {