diff options
author | Adam <Adam@anope.org> | 2016-07-03 13:29:27 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-07-03 13:29:27 -0400 |
commit | 8dc687b657205abefeb1a779ea42070721252e14 (patch) | |
tree | 3be15fa06f97359c4523000ec496cab9c93af678 /src/modes.cpp | |
parent | 18fc11398435a84a77219dc7332bed6e38c850d7 (diff) |
#1682: store aftype with masks and include cidrs in GetNUHMask
Diffstat (limited to 'src/modes.cpp')
-rw-r--r-- | src/modes.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/modes.cpp b/src/modes.cpp index 6760a610e..229945b7d 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -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 |