1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 08:56:39 +02:00

Add support for inspircd2.0+s mlock, improved on Unreal's, and made server side mlock usage configurable

This commit is contained in:
Adam
2012-05-23 19:35:56 -04:00
parent bf7d1a55af
commit 70fb5900a2
5 changed files with 74 additions and 5 deletions
+6
View File
@@ -192,6 +192,12 @@ chanserv
* These modes can not be locked or unlocked.
*/
require = "r"
/*
* Some IRCds can enforce mode locks server-side. This reduces the spam caused by
* services immediately reversing mode changes for locked modes.
*/
use_server_side_mlock = yes
}
/*
+2
View File
@@ -451,6 +451,8 @@ class CoreExport ServerConfig
Anope::string NoMLock;
/* Modes that are required to be on registered channels */
Anope::string CSRequire;
/* Use server side mlock */
bool UseServerSideMLock;
/* Default botmodes on channels, defaults to ao */
Anope::string BotModes;
/* THe actual modes */
+46 -1
View File
@@ -730,7 +730,7 @@ class ProtoInspIRCd : public Module
Capab.insert("NOQUIT");
Implementation i[] = { I_OnUserNickChange, I_OnServerSync };
Implementation i[] = { I_OnUserNickChange, I_OnServerSync, I_OnChannelCreate, I_OnChanRegistered, I_OnDelChan, I_OnMLock, I_OnUnMLock };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
if (Config->Numeric.empty())
@@ -766,6 +766,51 @@ class ProtoInspIRCd : public Module
nickserv->Validate(u);
}
}
void OnChannelCreate(Channel *c) anope_override
{
if (c->ci && Config->UseServerSideMLock)
this->OnChanRegistered(c->ci);
}
void OnChanRegistered(ChannelInfo *ci) anope_override
{
if (!Config->UseServerSideMLock)
return;
Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
UplinkSocket::Message(Me) << "METADATA " << ci->name << " mlock :" << modes;
}
void OnDelChan(ChannelInfo *ci) anope_override
{
if (!Config->UseServerSideMLock)
return;
UplinkSocket::Message(Me) << "METADATA " << ci->name << " mlock :";
}
EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
{
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Config->UseServerSideMLock)
{
Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->ModeChar;
UplinkSocket::Message(Me) << "METADATA " << ci->name << " mlock :" << modes;
}
return EVENT_CONTINUE;
}
EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
{
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Config->UseServerSideMLock)
{
Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->ModeChar, "");
UplinkSocket::Message(Me) << "METADATA " << ci->name << " mlock :" << modes;
}
return EVENT_CONTINUE;
}
};
MODULE_INIT(ProtoInspIRCd)
+19 -4
View File
@@ -1212,7 +1212,7 @@ class ProtoUnreal : public Module
this->AddModes();
Implementation i[] = { I_OnUserNickChange, I_OnChannelCreate, I_OnMLock, I_OnUnMLock };
Implementation i[] = { I_OnUserNickChange, I_OnChannelCreate, I_OnChanRegistered, I_OnDelChan, I_OnMLock, I_OnUnMLock };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
ModuleManager::SetPriority(this, PRIORITY_FIRST);
}
@@ -1232,17 +1232,32 @@ class ProtoUnreal : public Module
void OnChannelCreate(Channel *c) anope_override
{
if (Capab.count("MLOCK") > 0 && c->ci)
if (Config->UseServerSideMLock && Capab.count("MLOCK") > 0 && c->ci)
{
Anope::string modes = c->ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(c->creation_time) << " " << c->ci->name << " " << modes;
}
}
void OnChanRegistered(ChannelInfo *ci) anope_override
{
if (!ci->c || !Config->UseServerSideMLock)
return;
Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
}
void OnDelChan(ChannelInfo *ci) anope_override
{
if (!ci->c || !Config->UseServerSideMLock)
return;
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " :";
}
EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
{
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Capab.count("MLOCK") > 0)
if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Capab.count("MLOCK") > 0 && Config->UseServerSideMLock)
{
Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->ModeChar;
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
@@ -1254,7 +1269,7 @@ class ProtoUnreal : public Module
EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
{
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Capab.count("MLOCK") > 0)
if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Capab.count("MLOCK") > 0 && Config->UseServerSideMLock)
{
Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->ModeChar, "");
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
+1
View File
@@ -1253,6 +1253,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{"chanserv", "mlock", "+nrt", new ValueContainerString(&conf->MLock), DT_STRING | DT_ALLOW_EMPTY, NoValidation},
{"chanserv", "nomlock", "", new ValueContainerString(&conf->NoMLock), DT_STRING, NoValidation},
{"chanserv", "require", "", new ValueContainerString(&conf->CSRequire), DT_STRING, NoValidation},
{"chanserv", "use_server_side_mlock", "yes", new ValueContainerBool(&conf->UseServerSideMLock), DT_BOOLEAN, NoValidation},
{"memoserv", "name", "", new ValueContainerString(&conf->MemoServ), DT_STRING, NoValidation},
{"memoserv", "maxmemos", "0", new ValueContainerUInt(&conf->MSMaxMemos), DT_UINTEGER, NoValidation},
{"memoserv", "senddelay", "0", new ValueContainerTime(&conf->MSSendDelay), DT_TIME, NoValidation},