1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 03:06:37 +02:00

Make sockaddrs/cidr not throw on invalid ips to give us an easier/cheaper way to test for a valid IP

This commit is contained in:
Adam
2013-05-08 09:50:43 -04:00
parent 6859decfb8
commit 9b07e163c0
16 changed files with 212 additions and 244 deletions
+2 -7
View File
@@ -134,15 +134,10 @@ class ModuleDNSBL : public Module
/* At this time we only support IPv4 */
sockaddrs user_ip;
try
{
user_ip.pton(AF_INET, user->ip);
}
catch (const SocketException &)
{
user_ip.pton(AF_INET, user->ip);
if (!user_ip.valid())
/* User doesn't have a valid IPv4 IP (ipv6/spoof/etc) */
return;
}
const unsigned long &ip = user_ip.sa4.sin_addr.s_addr;
unsigned long reverse_ip = (ip << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | (ip >> 24);