aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/conf/inspircd.conf.example25
-rw-r--r--include/configreader.h9
-rw-r--r--include/xline.h3
-rw-r--r--src/configreader.cpp3
-rw-r--r--src/modules/m_rline.cpp2
-rw-r--r--src/usermanager.cpp14
-rw-r--r--src/xline.cpp29
7 files changed, 51 insertions, 34 deletions
diff --git a/docs/conf/inspircd.conf.example b/docs/conf/inspircd.conf.example
index 25d0a3a3a..be84c901f 100644
--- a/docs/conf/inspircd.conf.example
+++ b/docs/conf/inspircd.conf.example
@@ -640,6 +640,17 @@
# banned from the server.
xlinemessage="You're banned! Email irc@example.com with the ERROR line below for help."
+ # xlinequit: The quit message to show to opers and affected users when
+ # a user is [KGZ]-lined. The variables you can use in this are:
+ #
+ # %duration% - The duration of the X-line.
+ # %expiry% - The date/time at which the X-line expires.
+ # %reason% - The reason the X-line was added.
+ # %remaining% - The duration remaining on the X-line.
+ # %setter% - The name of the X-line setter.
+ # %type% - The type of X-line which was matched.
+ xlinequit="%type%-lined: %reason%"
+
# modesinlist: If enabled then the current channel modes will be shown
# in the /LIST response. Defaults to yes.
modesinlist="no"
@@ -767,10 +778,16 @@
# when a remote whois (/WHOIS <nick> <nick>) is used.
#hideserver="*.example.com"
- # hidelines: If defined then the quit message to show to unprivileged
- # users when another user is [KGZ]-lined. Can include %type% for the
- # X-line type and %reason% for the X-line reason.
- #hidelines="%type%-lined"
+ # publicxlinequit: The quit message to show to unprivileged users when
+ # a user is [KGZ]-lined. The variables you can use in this are:
+ #
+ # %duration% - The duration of the X-line.
+ # %expiry% - The date/time at which the X-line expires.
+ # %reason% - The reason the X-line was added.
+ # %remaining% - The duration remaining on the X-line.
+ # %setter% - The name of the X-line setter.
+ # %type% - The type of X-line which was matched.
+ #publicxlinequit="%type%-lined"
# hidekills: If defined, replaces who executed a /KILL with a custom string.
hidekills=""
diff --git a/include/configreader.h b/include/configreader.h
index f2d10bd05..17561e205 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -442,9 +442,6 @@ public:
/** The modes to set on a new channel. May contain channel prefix modes to set on the channel creator. */
std::string DefaultModes;
- /** If non-empty then the quit message to use when killing an X-lined user. */
- std::string HideLines;
-
/** If non-empty then the value to replace the server name with in public messages. */
std::string HideServer;
@@ -463,6 +460,12 @@ public:
/** The message to send to users when they are banned by an X-line. */
std::string XLineMessage;
+ /** The quit message to use when killing an X-lined user. */
+ std::string XLineQuit;
+
+ /** If non-empty then the public quit message to use when killing an X-lined user. */
+ std::string XLineQuitPublic;
+
/** The CIDR range to use when determining if IPv4 clients are from the same origin. */
unsigned char IPv4Range;
diff --git a/include/xline.h b/include/xline.h
index 53f5451c2..5a84e13ca 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -68,10 +68,9 @@ protected:
/** Default 'apply' action. Quits the user.
* @param u User to apply the line against
- * @param line The line typed, used for display purposes in the quit message
* @param bancache If true, the user will be added to the bancache if they match. Else not.
*/
- void DefaultApply(User* u, const std::string& line, bool bancache);
+ void DefaultApply(User* u, bool bancache);
public:
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 3a0b70534..7901a6826 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -365,6 +365,7 @@ void ServerConfig::Fill()
NoSnoticeStack = options->getBool("nosnoticestack");
SyntaxHints = options->getBool("syntaxhints");
XLineMessage = options->getString("xlinemessage", "You're banned!", 1);
+ XLineQuit = options->getString("xlinequit", "%type%-lined: %reason%", 1);
RestrictBannedUsers = options->getEnum("restrictbannedusers", ServerConfig::BUT_RESTRICT_NOTIFY, {
{ "no", ServerConfig::BUT_NORMAL },
{ "silent", ServerConfig::BUT_RESTRICT_SILENT },
@@ -386,9 +387,9 @@ void ServerConfig::Fill()
// Read the <security> config.
const auto& security = ConfValue("security");
CustomVersion = security->getString("customversion");
- HideLines = security->getString("hidelines", security->getBool("hidebans") ? "%type%-lined" : "");
HideServer = security->getString("hideserver", {}, InspIRCd::IsFQDN);
MaxTargets = security->getNum<size_t>("maxtargets", 5, 1, 50);
+ XLineQuitPublic = security->getString("publicxlinequit", security->getBool("hidebans") ? "%type%-lined" : "");
// Read the <cidr> config.
const auto& cidr = ConfValue("cidr");
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index ecdbbcc34..f303ca64a 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -87,7 +87,7 @@ public:
else
delete zl;
}
- DefaultApply(u, "R", false);
+ DefaultApply(u, false);
}
const std::string& Displayable() const override
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index db8fe0b5c..c7d22bf0d 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -207,17 +207,9 @@ void UserManager::AddUser(int socket, ListenSocket* via, const irc::sockets::soc
if (!ServerInstance->Config->XLineMessage.empty())
New->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage);
- 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);
- }
+ // IMPORTANT: we don't check XLineQuitPublic here because the only
+ // person who might see the ban at this point is the affected user.
+ this->QuitUser(New, b->Reason);
return;
}
else
diff --git a/src/xline.cpp b/src/xline.cpp
index 6889665b3..4c1a4e765 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -550,27 +550,32 @@ bool XLine::IsBurstable()
return !from_config;
}
-void XLine::DefaultApply(User* u, const std::string& line, bool bancache)
+void XLine::DefaultApply(User* u, bool bancache)
{
if (!ServerInstance->Config->XLineMessage.empty())
u->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage);
- const std::string banreason = line + "-lined: " + reason;
- if (ServerInstance->Config->HideLines.empty())
+ Template::VariableMap vars = {
+ { "duration", Duration::ToString(duration) },
+ { "expiry", Time::ToString(expiry) },
+ { "reason", reason },
+ { "remaining", Duration::ToString(ServerInstance->Time() - expiry) },
+ { "setter", source },
+ { "type", type },
+ };
+
+ const std::string banreason = Template::Replace(ServerInstance->Config->XLineQuit, vars);
+ if (ServerInstance->Config->XLineQuitPublic.empty())
ServerInstance->Users.QuitUser(u, banreason);
else
{
- const std::string publicreason = Template::Replace(ServerInstance->Config->HideLines,
- {
- { "reason", banreason },
- { "type", line },
- });
+ const std::string publicreason = Template::Replace(ServerInstance->Config->XLineQuitPublic, vars);
ServerInstance->Users.QuitUser(u, publicreason, &banreason);
}
if (bancache)
{
- ServerInstance->Logs.Debug("BANCACHE", "Adding positive hit (" + line + ") for " + u->GetAddress());
+ ServerInstance->Logs.Debug("BANCACHE", "Adding positive hit (" + type + ") for " + u->GetAddress());
ServerInstance->BanCache.AddHit(u->GetAddress(), this->type, banreason, (this->duration > 0 ? (this->expiry - ServerInstance->Time()) : 0));
}
}
@@ -595,7 +600,7 @@ bool KLine::Matches(User* u) const
void KLine::Apply(User* u)
{
- DefaultApply(u, "K", this->usermask == "*");
+ DefaultApply(u, this->usermask == "*");
}
bool GLine::Matches(User* u) const
@@ -618,7 +623,7 @@ bool GLine::Matches(User* u) const
void GLine::Apply(User* u)
{
- DefaultApply(u, "G", this->usermask == "*");
+ DefaultApply(u, this->usermask == "*");
}
bool ELine::Matches(User* u) const
@@ -646,7 +651,7 @@ bool ZLine::Matches(User* u) const
void ZLine::Apply(User* u)
{
- DefaultApply(u, "Z", true);
+ DefaultApply(u, true);
}
bool QLine::Matches(User* u) const