diff options
-rw-r--r-- | include/regchannel.h | 5 | ||||
-rw-r--r-- | src/bots.cpp | 1 | ||||
-rw-r--r-- | src/core/db_plain.cpp | 35 | ||||
-rw-r--r-- | src/modules/mysql/db_mysql_read.cpp | 60 | ||||
-rw-r--r-- | src/modules/mysql/db_mysql_write.cpp | 4 | ||||
-rw-r--r-- | src/protocol/inspircd12.cpp | 6 | ||||
-rw-r--r-- | src/regchannel.cpp | 73 | ||||
-rw-r--r-- | src/servers.cpp | 8 |
8 files changed, 114 insertions, 78 deletions
diff --git a/include/regchannel.h b/include/regchannel.h index e4c6fa6f5..e4e8bfdec 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -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 diff --git a/src/bots.cpp b/src/bots.cpp index a8cc86654..034472774 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -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"); } diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index 868374813..710d4eb50 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -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") { diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp index 79e59c9eb..1b4ce33fa 100644 --- a/src/modules/mysql/db_mysql_read.cpp +++ b/src/modules/mysql/db_mysql_read.cpp @@ -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; + std::vector<std::pair<std::string, std::string> > mlp; + std::string buf, buf2; + 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); - if (buf == cm->NameAsString) - { - sep.GetToken(buf); - ci->SetMLock(cm->Name, true, buf); - break; - } - } - } - } + 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()); diff --git a/src/modules/mysql/db_mysql_write.cpp b/src/modules/mysql/db_mysql_write.cpp index 2f7a42bb3..1888195f3 100644 --- a/src/modules/mysql/db_mysql_write.cpp +++ b/src/modules/mysql/db_mysql_write.cpp @@ -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) { diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index e125f45d0..d326b6820 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -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); diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 15a72ca87..d214eb6bd 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -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 diff --git a/src/servers.cpp b/src/servers.cpp index de7506c7e..88b326f47 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -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(); + } } /*************************************************************************/ |