1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 05:56:39 +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
+4 -5
View File
@@ -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 &) { }
}
}