summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-07 21:06:39 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-02-07 21:06:39 +0000
commit484c5aabf8afbb3dd104cbb208bae5e2efa98c02 (patch)
tree3ad03791da9c8f36d011e425684f1d30a2c99d39 /src
parentccf2e1468d1d98a3b6931fdd02ce8d73891cb037 (diff)
satmd tell me if this works, if ive got the wrong octet i need to change a bit of logic ops
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6544 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_dnsbl.cpp31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index ddcc2bd96..6c08655bb 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -63,29 +63,14 @@ class DNSBLResolver : public Resolver
if(result.length())
{
unsigned int bitmask=0;
- unsigned int octetpos=0;
- std::string tmp = result;
+ in_addr resultip;
- while(tmp.length()>0)
- {
- std::string octet;
- /* Fix by brain, npos is -1, so unsigned int will never match */
- std::string::size_type lastdot = tmp.rfind(".");
-
- if (lastdot == std::string::npos)
- {
- octet=tmp;
- tmp.clear();
- }
- else
- {
- octet=tmp.substr(lastdot+1,tmp.length()-lastdot+1);
- tmp.resize(lastdot);
- }
-
- bitmask += (256 ^ octetpos) * atoi(octet.c_str());
- octetpos += 1;
- }
+ /* Convert the result to an in_addr (we can gaurantee we got ipv4)
+ * Whoever did the loop that was here before, I AM CONFISCATING
+ * YOUR CRACKPIPE. you know who you are. -- Brain
+ */
+ inet_aton(result.c_str(), &resultip);
+ bitmask = resultip.s_addr & 0xFF; /* Last octet (network byte order */
bitmask &= ConfEntry->bitmask;
@@ -124,7 +109,7 @@ class DNSBLResolver : public Resolver
case DNSBLConfEntry::I_ZLINE:
{
ServerInstance->AddZLine(ConfEntry->duration, ServerInstance->Config->ServerName, reason, them->GetIPString());
- FOREACH_MOD(I_OnAddZLine,OnAddZLine(ConfEntry->duration, NULL, reason, them->GetIPString()));
+ FOREACH_MOD(I_OnAddZLine,OnAddZLine(ConfEntry->duration, NULL, reason, them->GetIPString()));
break;
}
case DNSBLConfEntry::I_UNKNOWN: