mirror of
https://github.com/anope/anope.git
synced 2026-06-28 21:56:37 +02:00
Dont load mlock from the database until after Anope is connected, it doesnt know all of the available modes until then
This commit is contained in:
@@ -232,6 +232,11 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag>
|
||||
*/
|
||||
void ClearBadWords();
|
||||
|
||||
/** Loads MLocked modes from extensible. This is used from database loading because Anope doesn't know what modes exist
|
||||
* until after it connects to the IRCd.
|
||||
*/
|
||||
void LoadMLock();
|
||||
|
||||
/** Check if a mode is mlocked
|
||||
* @param Name The mode
|
||||
* @param status True to check mlock on, false for mlock off
|
||||
|
||||
@@ -66,6 +66,7 @@ BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::
|
||||
|
||||
// If we're synchronised with the uplink already, call introduce_user() for this bot.
|
||||
if (Me && Me->GetUplink()->IsSynced())
|
||||
{
|
||||
ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid);
|
||||
ircdproto->SendSQLine(this->nick, "Reserved for services");
|
||||
}
|
||||
|
||||
+8
-27
@@ -793,39 +793,20 @@ class DBPlain : public Module
|
||||
{
|
||||
bool Set = key == "MLOCK_ON" ? true : false;
|
||||
|
||||
for (unsigned j = 0; j < params.size(); ++j)
|
||||
{
|
||||
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
|
||||
{
|
||||
if ((*it)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
|
||||
|
||||
if (cm->NameAsString == params[j])
|
||||
{
|
||||
ci->SetMLock(cm->Name, Set);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* For now store mlock in extensible, Anope hasn't yet connected to the IRCd and doesn't know what modes exist */
|
||||
ci->Extend(Set ? "db_mlock_modes_on" : "db_mlock_modes_off", new ExtensibleItemRegular<std::vector<std::string> >(params));
|
||||
}
|
||||
else if (key == "MLP")
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string> > mlp;
|
||||
|
||||
for (unsigned j = 0; j < params.size(); ++j, ++j)
|
||||
{
|
||||
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
|
||||
{
|
||||
if ((*it)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
|
||||
|
||||
if (cm->NameAsString == params[j])
|
||||
{
|
||||
ci->SetMLock(cm->Name, true, params[j + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
mlp.push_back(std::make_pair(params[j], params[j + 1]));
|
||||
}
|
||||
|
||||
/* For now store mlocked modes in extensible, Anope hasn't yet connected to the IRCd and doesn't know what modes exist */
|
||||
ci->Extend("db_mlp", new ExtensibleItemRegular<std::vector<std::pair<std::string, std::string> > >(mlp));
|
||||
}
|
||||
else if (key == "MI")
|
||||
{
|
||||
|
||||
@@ -272,67 +272,37 @@ static void LoadDatabase()
|
||||
ci->bantype = atoi(qres[i]["bantype"].c_str());
|
||||
if (qres[i]["mlock_on"].size())
|
||||
{
|
||||
std::vector<std::string> modes;
|
||||
std::string buf;
|
||||
|
||||
spacesepstream sep(SQLAssign(qres[i]["mlock_on"]));
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
|
||||
{
|
||||
if ((*it)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
|
||||
modes.push_back(buf);
|
||||
|
||||
if (buf == cm->NameAsString)
|
||||
{
|
||||
ci->SetMLock(cm->Name, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ci->Extend("db_mlock_modes_on", new ExtensibleItemRegular<std::vector<std::string> >(modes));
|
||||
}
|
||||
if (qres[i]["mlock_off"].size())
|
||||
{
|
||||
std::vector<std::string> modes;
|
||||
std::string buf;
|
||||
|
||||
spacesepstream sep(SQLAssign(qres[i]["mlock_off"]));
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
|
||||
{
|
||||
if ((*it)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
|
||||
modes.push_back(buf);
|
||||
|
||||
if (buf == cm->NameAsString)
|
||||
{
|
||||
ci->SetMLock(cm->Name, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ci->Extend("db_mlock_modes_off", new ExtensibleItemRegular<std::vector<std::string> >(modes));
|
||||
}
|
||||
if (qres[i]["mlock_params"].size())
|
||||
{
|
||||
std::string buf;
|
||||
spacesepstream sep(SQLAssign(qres[i]["mlock_params"]));
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
|
||||
{
|
||||
if ((*it)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
|
||||
std::vector<std::pair<std::string, std::string> > mlp;
|
||||
std::string buf, buf2;
|
||||
|
||||
if (buf == cm->NameAsString)
|
||||
{
|
||||
sep.GetToken(buf);
|
||||
ci->SetMLock(cm->Name, true, buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
spacesepstream sep(SQLAssign(qres[i]["mlock_params"]));
|
||||
|
||||
while (sep.GetToken(buf) && sep.GetToken(buf2))
|
||||
mlp.push_back(std::make_pair(buf, buf2));
|
||||
|
||||
ci->Extend("db_mlp", new ExtensibleItemRegular<std::vector<std::pair<std::string, std::string> > >(mlp));
|
||||
}
|
||||
if (qres[i]["entry_message"].size())
|
||||
ci->entry_message = sstrdup(qres[i]["entry_message"].c_str());
|
||||
|
||||
@@ -309,7 +309,7 @@ static void SaveDatabases()
|
||||
{
|
||||
AutoKick *ak = ci->GetAkick(j);
|
||||
|
||||
me->OnAkickAdd(ci, ak);
|
||||
me->OnAkickAdd(NULL, ci, ak);
|
||||
}
|
||||
|
||||
for (int k = 0; k < CA_SIZE; ++k)
|
||||
@@ -810,7 +810,7 @@ class DBMySQLWrite : public DBMySQL
|
||||
|
||||
void OnLevelChange(User *u, ChannelInfo *ci, int pos, int what)
|
||||
{
|
||||
mysqlpp::Query query(Me->Con);
|
||||
mysqlpp::Query query(me->Con);
|
||||
|
||||
if (pos >= 0)
|
||||
{
|
||||
|
||||
@@ -688,12 +688,10 @@ int anope_event_squit(const char *source, int ac, const char **av)
|
||||
int anope_event_rsquit(const char *source, int ac, const char **av)
|
||||
{
|
||||
/* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */
|
||||
Server *s = findserver(servlist, av[0]);
|
||||
if (!s)
|
||||
s = findserver_uid(servlist, av[0]);
|
||||
Server *s = Server::Find(av[0]);
|
||||
if (s && s->HasFlag(SERVER_JUPED))
|
||||
{
|
||||
send_cmd(TS6SID, "SQUIT %s :%s", s->suid, ac > 1 ? av[1] : "");
|
||||
send_cmd(TS6SID, "SQUIT %s :%s", s->GetSID().c_str(), ac > 1 ? av[1] : "");
|
||||
}
|
||||
|
||||
do_squit(source, ac, av);
|
||||
|
||||
@@ -371,6 +371,79 @@ void ChannelInfo::ClearBadWords()
|
||||
}
|
||||
}
|
||||
|
||||
/** Loads MLocked modes from extensible. This is used from database loading because Anope doesn't know what modes exist
|
||||
* until after it connects to the IRCd.
|
||||
*/
|
||||
void ChannelInfo::LoadMLock()
|
||||
{
|
||||
std::vector<std::string> modenames;
|
||||
|
||||
if (this->GetExtRegular("db_mlock_modes_on", modenames))
|
||||
{
|
||||
for (std::vector<std::string>::iterator it = modenames.begin(); it != modenames.end(); ++it)
|
||||
{
|
||||
for (std::list<Mode *>::iterator mit = ModeManager::Modes.begin(); mit != ModeManager::Modes.end(); ++mit)
|
||||
{
|
||||
if ((*mit)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*mit);
|
||||
|
||||
if (cm->NameAsString == *it)
|
||||
{
|
||||
this->SetMLock(cm->Name, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->Shrink("db_mlock_modes_on");
|
||||
}
|
||||
|
||||
if (this->GetExtRegular("db_mlock_modes_off", modenames))
|
||||
{
|
||||
for (std::vector<std::string>::iterator it = modenames.begin(); it != modenames.end(); ++it)
|
||||
{
|
||||
for (std::list<Mode *>::iterator mit = ModeManager::Modes.begin(); mit != ModeManager::Modes.end(); ++mit)
|
||||
{
|
||||
if ((*mit)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*mit);
|
||||
|
||||
if (cm->NameAsString == *it)
|
||||
{
|
||||
this->SetMLock(cm->Name, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->Shrink("db_mlock_modes_off");
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string> > params;
|
||||
|
||||
if (this->GetExtRegular("db_mlp", params))
|
||||
{
|
||||
for (std::vector<std::pair<std::string, std::string> >::iterator it = params.begin(); it != params.end(); ++it)
|
||||
{
|
||||
for (std::list<Mode *>::iterator mit = ModeManager::Modes.begin(); mit != ModeManager::Modes.end(); ++mit)
|
||||
{
|
||||
if ((*mit)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*mit);
|
||||
|
||||
if (cm->NameAsString == it->first)
|
||||
{
|
||||
this->SetMLock(cm->Name, true, it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->Shrink("db_mlp");
|
||||
}
|
||||
}
|
||||
|
||||
/** Check if a mode is mlocked
|
||||
* @param Name The mode
|
||||
* @param status True to check mlock on, false for mlock off
|
||||
|
||||
@@ -440,6 +440,14 @@ void CapabParse(int ac, const char **av)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Apply MLock now that we know what modes exist (capab is parsed after modes are added to Anope) */
|
||||
for (registered_channel_map::iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
|
||||
ci->LoadMLock();
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user