]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_dnsbl.cpp
GnuTLS: Send SSL client certificate when requested
[user/henk/code/inspircd.git] / src / modules / m_dnsbl.cpp
index 2ee71ce87300fecffa556bf115c9b64dbc2bd465..a2964a0bd036e6d79dea66df57df56a154085438 100644 (file)
@@ -27,9 +27,9 @@
 class DNSBLConfEntry : public classbase
 {
        public:
-               enum EnumBanaction { I_UNKNOWN, I_KILL, I_ZLINE, I_KLINE, I_GLINE };
+               enum EnumBanaction { I_UNKNOWN, I_KILL, I_ZLINE, I_KLINE, I_GLINE, I_MARK };
                enum EnumType { A_RECORD, A_BITMASK };
-               std::string name, domain, reason;
+               std::string name, ident, host, domain, reason;
                EnumBanaction banaction;
                EnumType type;
                long duration;
@@ -60,12 +60,8 @@ class DNSBLResolver : public Resolver
        }
 
        /* Note: This may be called multiple times for multiple A record results */
-       virtual void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached, int resultnum = 0)
+       virtual void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
        {
-               /* for bitmask reply types, we arent interested in any but the first result (number 0) */
-               if ((ConfEntry->type == DNSBLConfEntry::A_BITMASK) && (resultnum))
-                       return;
-
                /* Check the user still exists */
                if ((them) && (them == ServerInstance->SE->GetRef(theirfd)))
                {
@@ -111,6 +107,22 @@ class DNSBLResolver : public Resolver
                                                        ServerInstance->Users->QuitUser(them, std::string("Killed (") + reason + ")");
                                                        break;
                                                }
+                                               case DNSBLConfEntry::I_MARK:
+                                               {
+                                                       if (!ConfEntry->ident.empty())
+                                                       {
+                                                               them->WriteServ("304 " + them->nick + " :Your ident has been set to " + ConfEntry->ident + " because you matched " + reason);
+                                                               them->ChangeIdent(ConfEntry->ident.c_str());
+                                                       }
+
+                                                       if (!ConfEntry->host.empty())
+                                                       {
+                                                               them->WriteServ("304 " + them->nick + " :Your host has been set to " + ConfEntry->host + " because you matched " + reason);
+                                                               them->ChangeDisplayedHost(ConfEntry->host.c_str());
+                                                       }
+
+                                                       break;
+                                               }
                                                case DNSBLConfEntry::I_KLINE:
                                                {
                                                        KLine* kl = new KLine(ServerInstance, ServerInstance->Time(), ConfEntry->duration, ServerInstance->Config->ServerName, reason.c_str(),
@@ -160,7 +172,7 @@ class DNSBLResolver : public Resolver
                                                break;
                                        }
 
-                                       ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s detected as being on a DNS blacklist (%s) with result %d", them->GetFullRealHost().c_str(), ConfEntry->name.c_str(), (ConfEntry->type==DNSBLConfEntry::A_BITMASK) ? bitmask : record);
+                                       ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s detected as being on a DNS blacklist (%s) with result %d", them->GetFullRealHost().c_str(), ConfEntry->domain.c_str(), (ConfEntry->type==DNSBLConfEntry::A_BITMASK) ? bitmask : record);
                                }
                                else
                                        ConfEntry->stats_misses++;
@@ -197,6 +209,8 @@ class ModuleDNSBL : public Module
                        return DNSBLConfEntry::I_ZLINE;
                if(action.compare("GLINE")==0)
                        return DNSBLConfEntry::I_GLINE;
+               if(action.compare("MARK")==0)
+                       return DNSBLConfEntry::I_MARK;
 
                return DNSBLConfEntry::I_UNKNOWN;
        }
@@ -240,6 +254,8 @@ class ModuleDNSBL : public Module
                        DNSBLConfEntry *e = new DNSBLConfEntry();
 
                        e->name = MyConf->ReadValue("dnsbl", "name", i);
+                       e->ident = MyConf->ReadValue("dnsbl", "ident", i);
+                       e->host = MyConf->ReadValue("dnsbl", "host", i);
                        e->reason = MyConf->ReadValue("dnsbl", "reason", i);
                        e->domain = MyConf->ReadValue("dnsbl", "domain", i);
 
@@ -309,7 +325,7 @@ class ModuleDNSBL : public Module
                ReadConf();
        }
 
-       virtual int OnUserRegister(User* user)
+       virtual ModResult OnUserRegister(User* user)
        {
                /* only do lookups on local users */
                if (IS_LOCAL(user))
@@ -324,7 +340,7 @@ class ModuleDNSBL : public Module
                        success = inet_aton(user->GetIPString(), &in);
 
                        if (!success)
-                               return 0;
+                               return MOD_RES_PASSTHRU;
 
                        d = (unsigned char) (in.s_addr >> 24) & 0xFF;
                        c = (unsigned char) (in.s_addr >> 16) & 0xFF;
@@ -348,13 +364,13 @@ class ModuleDNSBL : public Module
                }
 
                /* don't do anything with this hot potato */
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 
-       virtual int OnStats(char symbol, User* user, string_list &results)
+       virtual ModResult OnStats(char symbol, User* user, string_list &results)
        {
                if (symbol != 'd')
-                       return 0;
+                       return MOD_RES_PASSTHRU;
 
                unsigned long total_hits = 0, total_misses = 0;
 
@@ -370,7 +386,7 @@ class ModuleDNSBL : public Module
                results.push_back(std::string(ServerInstance->Config->ServerName) + " 304 " + user->nick + " :DNSBLSTATS Total hits: " + ConvToStr(total_hits));
                results.push_back(std::string(ServerInstance->Config->ServerName) + " 304 " + user->nick + " :DNSBLSTATS Total misses: " + ConvToStr(total_misses));
 
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 };