summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2012-06-11 22:17:09 -0500
committerSir Poggles <sir.pogsalot@gmail.com>2012-06-12 22:49:29 -0700
commitfbf14cb9ff28ae1b8a6c4b90a18470381afbcc53 (patch)
treeaa5310f9be47ae3eaabf12f3235614f11f9dc5a5
parent5fd31ec5a6ba6021763b36d8d17d4665900623ab (diff)
m_dnsbl: switch to OnSetClientIP hook which may be refired.
-rw-r--r--src/modules/m_dnsbl.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index 2160b02dc..6a41c484f 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -243,7 +243,7 @@ class ModuleDNSBL : public Module
ReadConf();
ServerInstance->Modules->AddService(nameExt);
ServerInstance->Modules->AddService(countExt);
- Implementation eventlist[] = { I_OnRehash, I_OnUserInit, I_OnStats, I_OnSetConnectClass, I_OnCheckReady };
+ Implementation eventlist[] = { I_OnRehash, I_OnSetClientIP, I_OnStats, I_OnSetConnectClass, I_OnCheckReady };
ServerInstance->Modules->Attach(eventlist, this, 5);
}
@@ -348,22 +348,24 @@ class ModuleDNSBL : public Module
ReadConf();
}
- void OnUserInit(LocalUser* user)
+ void OnSetClientIP(User* user)
{
- if (user->exempt)
+ LocalUser *luser = IS_LOCAL(user);
+
+ if (!luser || luser->exempt)
return;
unsigned char a, b, c, d;
char reversedipbuf[128];
std::string reversedip;
- if (user->client_sa.sa.sa_family != AF_INET)
+ if (luser->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;
- a = (unsigned char) user->client_sa.in4.sin_addr.s_addr & 0xFF;
+ d = (unsigned char) (luser->client_sa.in4.sin_addr.s_addr >> 24) & 0xFF;
+ c = (unsigned char) (luser->client_sa.in4.sin_addr.s_addr >> 16) & 0xFF;
+ b = (unsigned char) (luser->client_sa.in4.sin_addr.s_addr >> 8) & 0xFF;
+ a = (unsigned char) luser->client_sa.in4.sin_addr.s_addr & 0xFF;
snprintf(reversedipbuf, 128, "%d.%d.%d.%d", d, c, b, a);
reversedip = std::string(reversedipbuf);
@@ -377,11 +379,11 @@ class ModuleDNSBL : public Module
/* now we'd need to fire off lookups for `hostname'. */
bool cached;
- DNSBLResolver *r = new DNSBLResolver(this, nameExt, countExt, hostname, user, DNSBLConfEntries[i], cached);
+ DNSBLResolver *r = new DNSBLResolver(this, nameExt, countExt, hostname, luser, DNSBLConfEntries[i], cached);
ServerInstance->AddResolver(r, cached);
i++;
}
- countExt.set(user, i);
+ countExt.set(luser, i);
}
ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass)