From 8dc687b657205abefeb1a779ea42070721252e14 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 3 Jul 2016 13:29:27 -0400 Subject: #1682: store aftype with masks and include cidrs in GetNUHMask --- src/modes.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/modes.cpp') 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(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 -- cgit