From 9b07e163c0e1ceed30e72aead2338b47ef2da1b2 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 8 May 2013 09:50:43 -0400 Subject: Make sockaddrs/cidr not throw on invalid ips to give us an easier/cheaper way to test for a valid IP --- modules/extra/m_proxyscan.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'modules/extra') diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp index da2ab5692..4e2a6bd88 100644 --- a/modules/extra/m_proxyscan.cpp +++ b/modules/extra/m_proxyscan.cpp @@ -149,14 +149,9 @@ class SOCKS5ProxyConnect : public ProxyConnect, public BinarySocket sockaddrs target_addr; char buf[4 + sizeof(target_addr.sa4.sin_addr.s_addr) + sizeof(target_addr.sa4.sin_port)]; int ptr = 0; - try - { - target_addr.pton(AF_INET, target_ip, target_port); - } - catch (const SocketException &) - { + target_addr.pton(AF_INET, target_ip, target_port); + if (!target_addr.valid()) return; - } buf[ptr++] = 5; // Version buf[ptr++] = 1; // # of methods @@ -340,15 +335,10 @@ class ModuleProxyScan : 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; - } if (!this->con_notice.empty() && !this->con_source.empty()) { -- cgit