* ---------------------------------------------------
*/
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdint.h>
#include "inspircd.h"
#include "xline.h"
#include "dns.h"
#include "channels.h"
#include "modules.h"
+#ifndef WINDOWS
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
/* $ModDesc: Provides handling of DNS blacklists */
/* Class holding data for a single entry */
userrec* them;
DNSBLConfEntry *ConfEntry;
- public:
+ public:
+
DNSBLResolver(Module *me, InspIRCd *ServerInstance, const std::string &hostname, userrec* u, int userfd, DNSBLConfEntry *conf, bool &cached)
: Resolver(ServerInstance, hostname, DNS_QUERY_A, cached, me)
{
case DNSBLConfEntry::I_KLINE:
{
std::string ban = std::string("*@") + them->GetIPString();
+ if (show)
+ ServerInstance->XLines->apply_lines(APPLY_KLINES);
show = ServerInstance->XLines->add_kline(ConfEntry->duration, ServerInstance->Config->ServerName, reason.c_str(), ban.c_str());
FOREACH_MOD(I_OnAddKLine,OnAddKLine(ConfEntry->duration, NULL, reason, ban));
break;
{
std::string ban = std::string("*@") + them->GetIPString();
show = ServerInstance->XLines->add_gline(ConfEntry->duration, ServerInstance->Config->ServerName, reason.c_str(), ban.c_str());
+ if (show)
+ ServerInstance->XLines->apply_lines(APPLY_GLINES);
FOREACH_MOD(I_OnAddGLine,OnAddGLine(ConfEntry->duration, NULL, reason, ban));
break;
}
case DNSBLConfEntry::I_ZLINE:
{
show = ServerInstance->XLines->add_zline(ConfEntry->duration, ServerInstance->Config->ServerName, reason.c_str(), them->GetIPString());
+ if (show)
+ ServerInstance->XLines->apply_lines(APPLY_ZLINES);
FOREACH_MOD(I_OnAddZLine,OnAddZLine(ConfEntry->duration, NULL, reason, them->GetIPString()));
break;
}
}
if (show)
+ {
ServerInstance->WriteOpers("*** Connecting user %s detected as being on a DNS blacklist (%s) with result %d", them->GetFullRealHost(), ConfEntry->name.c_str(), bitmask);
+ }
}
else
ConfEntry->stats_misses++;
return DNSBLConfEntry::I_UNKNOWN;
}
public:
- ModuleDNSBL(InspIRCd *Me) : Module::Module(Me)
+ ModuleDNSBL(InspIRCd *Me) : Module(Me)
{
ReadConf();
}
e->reason = MyConf->ReadValue("dnsbl", "reason", i);
e->domain = MyConf->ReadValue("dnsbl", "domain", i);
e->banaction = str2banaction(MyConf->ReadValue("dnsbl", "action", i));
- e->duration = ServerInstance->Duration(MyConf->ReadValue("dnsbl", "duration", i).c_str());
+ e->duration = ServerInstance->Duration(MyConf->ReadValue("dnsbl", "duration", i));
e->bitmask = MyConf->ReadInteger("dnsbl", "bitmask", i, false);
/* yeah, logic here is a little messy */
{
ServerInstance->WriteOpers("*** DNSBL(#%d): invalid bitmask",i);
}
- else if (e->name == "")
+ else if (e->name.empty())
{
ServerInstance->WriteOpers("*** DNSBL(#%d): Invalid name",i);
}
- else if (e->domain == "")
+ else if (e->domain.empty())
{
ServerInstance->WriteOpers("*** DNSBL(#%d): Invalid domain",i);
}
}
else
{
- if (e->reason == "")
+ if (e->reason.empty())
{
ServerInstance->WriteOpers("*** DNSBL(#%d): empty reason, using defaults",i);
e->reason = "Your IP has been blacklisted.";
ReadConf();
}
- /*
- * We will check each user that connects *locally* (userrec::fd>0)
- */
virtual int OnUserRegister(userrec* user)
{
+ /* only do lookups on local users */
if (IS_LOCAL(user))
{
/* following code taken from bopm, reverses an IP address. */
};
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
{
return new ModuleDNSBLFactory;
}