mirror of
https://github.com/anope/anope.git
synced 2026-07-03 02:43:13 +02:00
#1682: store aftype with masks and include cidrs in GetNUHMask
This commit is contained in:
+20
-8
@@ -742,7 +742,7 @@ void ModeManager::StackerDel(Mode *m)
|
||||
}
|
||||
}
|
||||
|
||||
Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh), cidr_len(0)
|
||||
Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh), cidr_len(0), family(0)
|
||||
{
|
||||
Anope::string n, u, h;
|
||||
|
||||
@@ -802,14 +802,13 @@ Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh
|
||||
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.
|
||||
* If cidr_len is >32 (or 128) it is handled later in
|
||||
* cidr::match
|
||||
*/
|
||||
|
||||
/* If we got here, cidr_len is a valid number. */
|
||||
|
||||
this->host = cidr_ip;
|
||||
this->family = addr.family();
|
||||
|
||||
Log(LOG_DEBUG) << "Ban " << m << " has cidr " << this->cidr_len;
|
||||
Log(LOG_DEBUG) << "Ban " << mask << " has cidr " << this->cidr_len;
|
||||
}
|
||||
}
|
||||
catch (const ConvertException &) { }
|
||||
@@ -830,8 +829,21 @@ const Anope::string Entry::GetNUHMask() const
|
||||
Anope::string n = nick.empty() ? "*" : nick,
|
||||
u = user.empty() ? "*" : user,
|
||||
h = host.empty() ? "*" : host,
|
||||
r = real.empty() ? "" : "#" + real;
|
||||
return n + "!" + u + "@" + h + r;
|
||||
r = real.empty() ? "" : "#" + real,
|
||||
c;
|
||||
switch (family)
|
||||
{
|
||||
case AF_INET:
|
||||
if (cidr_len <= 32)
|
||||
c = "/" + stringify(cidr_len);
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (cidr_len <= 128)
|
||||
c = "/" + stringify(cidr_len);
|
||||
break;
|
||||
}
|
||||
|
||||
return n + "!" + u + "@" + h + c + r;
|
||||
}
|
||||
|
||||
bool Entry::Matches(User *u, bool full) const
|
||||
|
||||
Reference in New Issue
Block a user