aboutsummaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 494b58003..625f6a446 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -254,10 +254,10 @@ Membership* Channel::ForceJoin(User* user, const std::string* privs, bool bursti
return memb;
}
-bool Channel::IsBanned(User* user)
+bool Channel::IsBanned(User* user, const std::optional<bool>& full)
{
ModResult result;
- FIRST_MOD_RESULT(OnCheckChannelBan, result, (user, this));
+ FIRST_MOD_RESULT(OnCheckChannelBan, result, (user, this, full.value_or(ServerInstance->Config->BanRealMask)));
if (result != MOD_RES_PASSTHRU)
return (result == MOD_RES_DENY);
@@ -271,17 +271,19 @@ bool Channel::IsBanned(User* user)
{
for (const auto& entry : *bans)
{
- if (CheckBan(user, entry.mask))
+ if (CheckBan(user, entry.mask, full))
return true;
}
}
return false;
}
-bool Channel::CheckBan(User* user, const std::string& mask)
+bool Channel::CheckBan(User* user, const std::string& mask, const std::optional<bool>& ofull)
{
+ auto full = ofull.value_or(ServerInstance->Config->BanRealMask);
+
ModResult result;
- FIRST_MOD_RESULT(OnCheckBan, result, (user, this, mask));
+ FIRST_MOD_RESULT(OnCheckBan, result, (user, this, mask, full));
if (result != MOD_RES_PASSTHRU)
return (result == MOD_RES_DENY);
@@ -291,16 +293,18 @@ bool Channel::CheckBan(User* user, const std::string& mask)
const std::string prefix(mask, 0, at);
if (!InspIRCd::Match(user->nick + "!" + user->GetDisplayedUser(), prefix) &&
- !InspIRCd::Match(user->nick + "!" + user->GetRealUser(), prefix))
+ (!full || !InspIRCd::Match(user->nick + "!" + user->GetRealUser(), prefix)))
{
- // Neither the nick!user or nick!duser.
+ // Neither the nick!user or nick!duser match.
return false;
}
const std::string suffix(mask, at + 1);
- return InspIRCd::Match(user->GetRealHost(), suffix) ||
- InspIRCd::Match(user->GetDisplayedHost(), suffix) ||
- InspIRCd::MatchCIDR(user->GetAddress(), suffix);
+ if (InspIRCd::Match(user->GetDisplayedHost(), suffix))
+ return true; // The dhost matches.
+
+ return full && (InspIRCd::Match(user->GetRealHost(), suffix)
+ || InspIRCd::MatchCIDR(user->GetAddress(), suffix)); // The rhost or IP match.
}
void Channel::PartUser(const MemberMap::iterator& membiter, const std::string& reason)