aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-03-26 22:39:42 +0100
committerGravatar Sadie Powell2023-04-18 14:21:11 +0100
commitf8614ea98581fb303abc36c792be6ba60b3c8b42 (patch)
tree4c2840b444072bb6dd11debdc50077d0e854fc3d /src
parentMarginally improve the performance of JSON logging. (diff)
Allow customising the message shown when hiding an X-line ban.
Diffstat (limited to 'src')
-rw-r--r--src/configreader.cpp2
-rw-r--r--src/usermanager.cpp14
-rw-r--r--src/xline.cpp18
3 files changed, 24 insertions, 10 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index d500a0fbd..4803fdb7d 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -340,7 +340,7 @@ void ServerConfig::Fill()
// Read the <security> config.
const auto& security = ConfValue("security");
CustomVersion = security->getString("customversion");
- HideBans = security->getBool("hidebans");
+ HideLines = security->getString("hidelines", security->getBool("hidebans") ? "%type%-lined" : "");
HideServer = security->getString("hideserver", {}, InspIRCd::IsFQDN);
MaxTargets = security->getNum<unsigned long>("maxtargets", 5, 1, 50);
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 1b64f61f9..c706d8d90 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -203,13 +203,21 @@ void UserManager::AddUser(int socket, ListenSocket* via, const irc::sockets::soc
{
/* user banned */
ServerInstance->Logs.Debug("BANCACHE", "BanCache: Positive hit for " + New->GetAddress());
+
if (!ServerInstance->Config->XLineMessage.empty())
New->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage);
- if (ServerInstance->Config->HideBans)
- this->QuitUser(New, b->Type + "-lined", &b->Reason);
- else
+ if (ServerInstance->Config->HideLines.empty())
this->QuitUser(New, b->Reason);
+ else
+ {
+ const std::string publicreason = Template::Replace(ServerInstance->Config->HideLines,
+ {
+ { "reason", b->Reason },
+ { "type", b->Type },
+ });
+ this->QuitUser(New, publicreason, &b->Reason);
+ }
return;
}
else
diff --git a/src/xline.cpp b/src/xline.cpp
index 6cc44447f..c4b3b9287 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -564,20 +564,26 @@ bool XLine::IsBurstable()
void XLine::DefaultApply(User* u, const std::string& line, bool bancache)
{
- const std::string banReason = line + "-lined: " + reason;
-
if (!ServerInstance->Config->XLineMessage.empty())
u->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage);
- if (ServerInstance->Config->HideBans)
- ServerInstance->Users.QuitUser(u, line + "-lined", &banReason);
+ const std::string banreason = line + "-lined: " + reason;
+ if (ServerInstance->Config->HideLines.empty())
+ ServerInstance->Users.QuitUser(u, banreason);
else
- ServerInstance->Users.QuitUser(u, banReason);
+ {
+ const std::string publicreason = Template::Replace(ServerInstance->Config->HideLines,
+ {
+ { "reason", banreason },
+ { "type", line },
+ });
+ ServerInstance->Users.QuitUser(u, publicreason, &banreason);
+ }
if (bancache)
{
ServerInstance->Logs.Debug("BANCACHE", "BanCache: Adding positive hit (" + line + ") for " + u->GetAddress());
- ServerInstance->BanCache.AddHit(u->GetAddress(), this->type, banReason, (this->duration > 0 ? (this->expiry - ServerInstance->Time()) : 0));
+ ServerInstance->BanCache.AddHit(u->GetAddress(), this->type, banreason, (this->duration > 0 ? (this->expiry - ServerInstance->Time()) : 0));
}
}