Add a way to disable certain capabilities

This is a way for admins to mitigate some issues caused by caps if such issues ever arise.

E.g. add this to global level in znc.conf:

DisableClientCap = sasl
DisableServerCap = chghost
DisableServerCap = message-tags

Then these caps will be NAKed to client / not requested from server.

Note that this mechanism doesn't fully prevent a cap from being activated, e.g. one could use *send_raw module to request it from server even when disabled.
This commit is contained in:
Alexey Sokolov
2025-05-08 21:55:40 +01:00
parent 1063b7f5d6
commit 1c197a5508
5 changed files with 58 additions and 4 deletions
+24
View File
@@ -1104,5 +1104,29 @@ TEST_F(ZNCTest, InviteNotify) {
ASSERT_THAT(ircd.ReadRemainder().toStdString(), Not(HasSubstr("__INV__")));
}
TEST_F(ZNCTest, DisableCap) {
{
QFile conf(m_dir.path() + "/configs/znc.conf");
ASSERT_TRUE(conf.open(QIODevice::Append | QIODevice::Text));
QTextStream out(&conf);
out << R"(
DisableClientCap = sasl
DisableServerCap = chghost
)";
}
auto znc = Run();
auto ircd = ConnectIRCd();
ircd.Write("CAP user LS :chghost");
ASSERT_THAT(ircd.ReadRemainder().toStdString(), Not(HasSubstr("chghost")));
auto client = ConnectClient();
client.Write("NICK foo");
client.Write("CAP LS 302");
ASSERT_THAT(client.ReadRemainder().toStdString(), Not(HasSubstr("sasl")));
client.Write("CAP REQ sasl");
client.ReadUntil("CAP foo NAK :sasl");
}
} // namespace
} // namespace znc_inttest