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 /src/modes.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 'src/modes.cpp')
-rw-r--r-- | src/modes.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/modes.cpp b/src/modes.cpp index 9481f570e..1238df17d 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -671,12 +671,12 @@ Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh { const Anope::string &cidr_ip = this->host.substr(0, sl), &cidr_range = this->host.substr(sl + 1); + + sockaddrs addr(cidr_ip); + try { - sockaddrs addr(cidr_ip); - /* If we got here, cidr_ip is a valid ip */ - - if (cidr_range.is_pos_number_only()) + if (addr.valid() && cidr_range.is_pos_number_only()) { this->cidr_len = convertTo<unsigned short>(cidr_range); /* If we got here, cidr_len is a valid number. @@ -689,7 +689,6 @@ Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh Log(LOG_DEBUG) << "Ban " << this->mask << " has cidr " << this->cidr_len; } } - catch (const SocketException &) { } catch (const ConvertException &) { } } } |