]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_dnsbl.cpp
Remove some uline checks that ran after an IS_LOCAL() check
[user/henk/code/inspircd.git] / src / modules / m_dnsbl.cpp
index 5b0dd366b809059632df88cfb6076f09fa959bec..5e02dd0a5dadc5cea64d99375285f24a5a8bb5e6 100644 (file)
@@ -22,6 +22,7 @@
 
 
 #include "inspircd.h"
+#include "xline.h"
 
 /* $ModDesc: Provides handling of DNS blacklists */
 
@@ -239,7 +240,7 @@ class ModuleDNSBL : public Module
                ServerInstance->Modules->AddService(nameExt);
                ServerInstance->Modules->AddService(countExt);
                Implementation eventlist[] = { I_OnRehash, I_OnSetUserIP, I_OnStats, I_OnSetConnectClass, I_OnCheckReady };
-               ServerInstance->Modules->Attach(eventlist, this, 5);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        virtual ~ModuleDNSBL()
@@ -351,16 +352,21 @@ class ModuleDNSBL : public Module
 
        void OnSetUserIP(LocalUser* user)
        {
-               if (user->exempt)
+               if ((user->exempt) || (user->client_sa.sa.sa_family != AF_INET))
                        return;
 
+               if (user->MyClass)
+               {
+                       if (!user->MyClass->config->getBool("usednsbl", true))
+                               return;
+               }
+               else
+                       ServerInstance->Logs->Log("m_dnsbl", DEBUG, "User has no connect class in OnSetUserIP");
+
                unsigned char a, b, c, d;
                char reversedipbuf[128];
                std::string reversedip;
 
-               if (user->client_sa.sa.sa_family != AF_INET)
-                       return;
-
                d = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 24) & 0xFF;
                c = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 16) & 0xFF;
                b = (unsigned char) (user->client_sa.in4.sin_addr.s_addr >> 8) & 0xFF;
@@ -369,6 +375,8 @@ class ModuleDNSBL : public Module
                snprintf(reversedipbuf, 128, "%d.%d.%d.%d", d, c, b, a);
                reversedip = std::string(reversedipbuf);
 
+               countExt.set(user, DNSBLConfEntries.size());
+
                // For each DNSBL, we will run through this lookup
                unsigned int i = 0;
                while (i < DNSBLConfEntries.size())
@@ -380,9 +388,10 @@ class ModuleDNSBL : public Module
                        bool cached;
                        DNSBLResolver *r = new DNSBLResolver(this, nameExt, countExt, hostname, user, DNSBLConfEntries[i], cached);
                        ServerInstance->AddResolver(r, cached);
+                       if (user->quitting)
+                               break;
                        i++;
                }
-               countExt.set(user, i);
        }
 
        ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass)
@@ -416,12 +425,12 @@ class ModuleDNSBL : public Module
                        total_hits += (*i)->stats_hits;
                        total_misses += (*i)->stats_misses;
 
-                       results.push_back(std::string(ServerInstance->Config->ServerName.c_str()) + " 304 " + user->nick + " :DNSBLSTATS DNSbl \"" + (*i)->name + "\" had " +
+                       results.push_back(ServerInstance->Config->ServerName + " 304 " + user->nick + " :DNSBLSTATS DNSbl \"" + (*i)->name + "\" had " +
                                        ConvToStr((*i)->stats_hits) + " hits and " + ConvToStr((*i)->stats_misses) + " misses");
                }
 
-               results.push_back(std::string(ServerInstance->Config->ServerName.c_str()) + " 304 " + user->nick + " :DNSBLSTATS Total hits: " + ConvToStr(total_hits));
-               results.push_back(std::string(ServerInstance->Config->ServerName.c_str()) + " 304 " + user->nick + " :DNSBLSTATS Total misses: " + ConvToStr(total_misses));
+               results.push_back(ServerInstance->Config->ServerName + " 304 " + user->nick + " :DNSBLSTATS Total hits: " + ConvToStr(total_hits));
+               results.push_back(ServerInstance->Config->ServerName + " 304 " + user->nick + " :DNSBLSTATS Total misses: " + ConvToStr(total_misses));
 
                return MOD_RES_PASSTHRU;
        }