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/protocol/unreal.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/protocol/unreal.cpp')
-rw-r--r-- | modules/protocol/unreal.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 4186ee5d0..ea5da3dbe 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -46,14 +46,15 @@ class UnrealIRCdProto : public IRCDProto return; /* ZLine if we can instead */ - if (x->GetUser() == "*" && x->GetHost().find_first_not_of("0123456789:.") == Anope::string::npos) - try + if (x->GetUser() == "*") + { + sockaddrs a(x->GetHost()); + if (a.valid()) { - sockaddrs(x->GetHost()); IRCD->SendSZLineDel(x); return; } - catch (const SocketException &) { } + } UplinkSocket::Message() << "TKL - G " << x->GetUser() << " " << x->GetHost() << " " << x->by; } @@ -108,14 +109,15 @@ class UnrealIRCdProto : public IRCDProto } /* ZLine if we can instead */ - if (x->GetUser() == "*" && x->GetHost().find_first_not_of("0123456789:.") == Anope::string::npos) - try + if (x->GetUser() == "*") + { + sockaddrs a(x->GetHost()); + if (a.valid()) { - sockaddrs(x->GetHost()); IRCD->SendSZLine(u, x); return; } - catch (const SocketException &) { } + } // Calculate the time left before this would expire, capping it at 2 days time_t timeleft = x->expires - Anope::CurTime; @@ -786,13 +788,9 @@ struct IRCDMessageNick : IRCDMessage Anope::string decoded_ip; Anope::B64Decode(params[9], decoded_ip); - try - { - sockaddrs ip_addr; - ip_addr.ntop(params[9].length() == 8 ? AF_INET : AF_INET6, decoded_ip.c_str()); - ip = ip_addr.addr(); - } - catch (const SocketException &ex) { } + sockaddrs ip_addr; + ip_addr.ntop(params[9].length() == 8 ? AF_INET : AF_INET6, decoded_ip.c_str()); + ip = ip_addr.addr(); } Anope::string vhost = params[8]; |