diff options
author | Adam <Adam@anope.org> | 2013-05-08 09:50:43 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-05-08 09:50:43 -0400 |
commit | 9b07e163c0e1ceed30e72aead2338b47ef2da1b2 (patch) | |
tree | 4c13bd545846700a58c5526c3e4e9a6fdf0afc87 /modules/m_dnsbl.cpp | |
parent | 6859decfb8ed0430e946ff81eca4f9da879f69c9 (diff) |
Make sockaddrs/cidr not throw on invalid ips to give us an easier/cheaper way to test for a valid IP
Diffstat (limited to 'modules/m_dnsbl.cpp')
-rw-r--r-- | modules/m_dnsbl.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/modules/m_dnsbl.cpp b/modules/m_dnsbl.cpp index ea1f1d9f6..08d4e365d 100644 --- a/modules/m_dnsbl.cpp +++ b/modules/m_dnsbl.cpp @@ -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); |