summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-06-02 14:59:34 -0400
committerAdam <Adam@anope.org>2011-06-02 14:59:34 -0400
commit3ad93a31c91ae096d5e53deb7dd64586fa935244 (patch)
tree46a53929245681c142cb58c25d20754ac1f15fc8
parent184b346166db9d40fcdc7bb6bf3a7929fdd48be9 (diff)
Burst our channels with the uplink when we connect & fixed bug #1274
-rw-r--r--include/services.h2
-rw-r--r--modules/protocol/bahamut.cpp7
-rw-r--r--modules/protocol/inspircd-ts6.h12
-rw-r--r--modules/protocol/inspircd11.cpp7
-rw-r--r--modules/protocol/plexus.cpp7
-rw-r--r--modules/protocol/ratbox.cpp2
-rw-r--r--modules/protocol/unreal.cpp7
-rw-r--r--src/init.cpp43
-rw-r--r--src/regchannel.cpp57
-rw-r--r--src/servers.cpp76
10 files changed, 120 insertions, 100 deletions
diff --git a/include/services.h b/include/services.h
index 35342e1da..539d0e06c 100644
--- a/include/services.h
+++ b/include/services.h
@@ -868,7 +868,7 @@ class CoreExport IRCDProto
virtual void SendQuit(const User *u, const char *fmt, ...);
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
- virtual void SendJoin(BotInfo *, Channel *, const ChannelStatus *) = 0;
+ virtual void SendJoin(User *, Channel *, const ChannelStatus *) = 0;
virtual void SendSQLineDel(const XLine *x) { }
virtual void SendInvite(const BotInfo *bi, const Anope::string &chan, const Anope::string &nick);
virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...);
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 29f16004e..ff2cab4d2 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -161,13 +161,16 @@ class BahamutIRCdProto : public IRCDProto
}
/* JOIN - SJOIN */
- void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status)
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status)
{
send_cmd(user->nick, "SJOIN %ld %s", static_cast<long>(c->creation_time), c->name.c_str());
if (status)
+ {
+ BotInfo *setter = findbot(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
if (status->HasFlag(ModeManager::ChannelModes[i]->Name))
- c->SetMode(user, ModeManager::ChannelModes[i], user->nick, false);
+ c->SetMode(setter, ModeManager::ChannelModes[i], user->nick, false);
+ }
}
void SendAkill(User *, const XLine *x)
diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h
index cf93865f8..54a615aaf 100644
--- a/modules/protocol/inspircd-ts6.h
+++ b/modules/protocol/inspircd-ts6.h
@@ -128,7 +128,7 @@ class InspIRCdTS6Proto : public IRCDProto
}
/* JOIN */
- void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status)
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status)
{
send_cmd(Config->Numeric, "FJOIN %s %ld +%s :,%s", c->name.c_str(), static_cast<long>(c->creation_time), c->GetModes(true, true).c_str(), user->GetUID().c_str());
/* Note that we can send this with the FJOIN but choose not to
@@ -136,9 +136,12 @@ class InspIRCdTS6Proto : public IRCDProto
* merge these modes with +nrt and other mlocked modes
*/
if (status)
+ {
+ BotInfo *setter = findbot(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
if (status->HasFlag(ModeManager::ChannelModes[i]->Name))
- c->SetMode(user, ModeManager::ChannelModes[i], user->nick, false);
+ c->SetMode(setter, ModeManager::ChannelModes[i], user->nick, false);
+ }
}
/* UNSQLINE */
@@ -245,10 +248,7 @@ class InspIRCdTS6Proto : public IRCDProto
void SendChannel(Channel *c)
{
- Anope::string modes = c->GetModes(true, true);
- if (modes.empty())
- modes = "+";
- send_cmd(Config->Numeric, "FJOIN %s %ld %s :", c->name.c_str(), static_cast<long>(c->creation_time), modes.c_str());
+ send_cmd(Config->Numeric, "FJOIN %s %ld +%s :", c->name.c_str(), static_cast<long>(c->creation_time), c->GetModes(true, true).c_str());
}
bool IsNickValid(const Anope::string &nick)
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index a382d4006..1790aaa84 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -160,13 +160,16 @@ class InspIRCdProto : public IRCDProto
}
/* JOIN */
- void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status)
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status)
{
send_cmd(user->nick, "JOIN %s %ld", c->name.c_str(), static_cast<long>(c->creation_time));
if (status)
+ {
+ BotInfo *setter = findbot(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
if (status->HasFlag(ModeManager::ChannelModes[i]->Name))
- c->SetMode(user, ModeManager::ChannelModes[i], user->nick, false);
+ c->SetMode(setter, ModeManager::ChannelModes[i], user->nick, false);
+ }
}
/* UNSQLINE */
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 5e6c67781..c83aa786e 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -122,13 +122,16 @@ class PlexusProto : public IRCDProto
send_cmd(Config->Numeric, "UNRESV * %s", x->Mask.c_str());
}
- void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status)
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status)
{
send_cmd(Config->Numeric, "SJOIN %ld %s +%s :%s", static_cast<long>(c->creation_time), c->name.c_str(), c->GetModes(true, true).c_str(), user->GetUID().c_str());
if (status)
+ {
+ BotInfo *setter = findbot(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
if (status->HasFlag(ModeManager::ChannelModes[i]->Name))
- c->SetMode(user, ModeManager::ChannelModes[i], user->nick, false);
+ c->SetMode(setter, ModeManager::ChannelModes[i], user->nick, false);
+ }
}
void SendAkill(User *, const XLine *x)
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index 2833c52b7..13a5e287a 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -125,7 +125,7 @@ class RatboxProto : public IRCDProto
send_cmd(Config->Numeric, "UNRESV * %s", x->Mask.c_str());
}
- void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status)
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status)
{
/* Note that we must send our modes with the SJOIN and
* can not add them to the mode stacker because ratbox
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index e07b97af0..9e7768ef3 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -172,13 +172,16 @@ class UnrealIRCdProto : public IRCDProto
}
/* JOIN */
- void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status)
+ void SendJoin(User *user, Channel *c, const ChannelStatus *status)
{
send_cmd(Config->ServerName, "~ %ld %s :%s", static_cast<long>(c->creation_time), c->name.c_str(), user->nick.c_str());
if (status)
+ {
+ BotInfo *setter = findbot(user->nick);
for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
if (status->HasFlag(ModeManager::ChannelModes[i]->Name))
- c->SetMode(user, ModeManager::ChannelModes[i], user->nick, false);
+ c->SetMode(setter, ModeManager::ChannelModes[i], user->nick, false);
+ }
}
/* unsqline
diff --git a/src/init.cpp b/src/init.cpp
index 0f3a5650d..96771eff0 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -23,44 +23,9 @@ void introduce_user(const Anope::string &user)
throw FatalException("introduce_user loop detected");
lasttime = now;
- if (!user.empty())
+ User *u = finduser(user);
+ if (u)
{
- User *u = finduser(user);
- if (u)
- {
- ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
-
- BotInfo *bi = findbot(u->nick);
- if (bi)
- {
- XLine x(bi->nick, "Reserved for services");
- ircdproto->SendSQLine(NULL, &x);
-
- for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
- ircdproto->SendJoin(bi, (*cit)->chan, &Config->BotModeList);
- }
- }
-
- return;
- }
-
- ircdproto->SendBOB();
-
- for (unsigned i = 0; i < Me->GetLinks().size(); ++i)
- {
- Server *s = Me->GetLinks()[i];
-
- if (s->HasFlag(SERVER_JUPED))
- {
- ircdproto->SendServer(s);
- }
- }
-
- /* We make the bots go online */
- for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
- {
- User *u = it->second;
-
ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
BotInfo *bi = findbot(u->nick);
@@ -73,10 +38,6 @@ void introduce_user(const Anope::string &user)
ircdproto->SendJoin(bi, (*cit)->chan, &Config->BotModeList);
}
}
-
- /* Load MLock from the database now that we know what modes exist */
- for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
- it->second->LoadMLock();
}
/*************************************************************************/
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 1bd8807d9..be2746edf 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -542,6 +542,9 @@ void ChannelInfo::ClearBadWords()
*/
void ChannelInfo::LoadMLock()
{
+ if (!this->GetExt("db_mlock"))
+ return;
+
this->ClearMLock();
// Force +r
@@ -550,51 +553,27 @@ void ChannelInfo::LoadMLock()
this->SetMLock(chm, true);
std::vector<Anope::string> mlock;
- if (this->GetExtRegular("db_mlock", mlock))
+ this->GetExtRegular("db_mlock", mlock);
+ for (unsigned i = 0; i < mlock.size(); ++i)
{
- for (unsigned i = 0; i < mlock.size(); ++i)
- {
- std::vector<Anope::string> mlockv = BuildStringVector(mlock[i]);
-
- bool set = mlockv[0] == "1";
- ChannelMode *cm = ModeManager::FindChannelModeByString(mlockv[1]);
- const Anope::string &setter = mlockv[2];
- time_t created = Anope::CurTime;
- try
- {
- created = convertTo<time_t>(mlockv[3]);
- }
- catch (const ConvertException &) { }
- const Anope::string &param = mlockv.size() > 4 ? mlockv[4] : "";
-
- if (cm != NULL)
- this->SetMLock(cm, set, param, setter, created);
- }
+ std::vector<Anope::string> mlockv = BuildStringVector(mlock[i]);
- this->Shrink("db_mlock");
- }
-
- /* Create perm channel */
- if (this->HasFlag(CI_PERSIST) && !this->c)
- {
- this->c = new Channel(this->name, this->time_registered);
- if (ModeManager::FindChannelModeByName(CMODE_PERM) != NULL)
+ bool set = mlockv[0] == "1";
+ ChannelMode *cm = ModeManager::FindChannelModeByString(mlockv[1]);
+ const Anope::string &setter = mlockv[2];
+ time_t created = Anope::CurTime;
+ try
{
- /* At this point, CMODE_PERM *must* be locked on the channel, so this is fine */
- ircdproto->SendChannel(this->c);
- this->c->Reset();
+ created = convertTo<time_t>(mlockv[3]);
}
- else
- {
- if (!this->bi)
- this->WhoSends()->Assign(NULL, this);
- if (this->c->FindUser(this->bi) == NULL)
- this->bi->Join(this->c);
+ catch (const ConvertException &) { }
+ const Anope::string &param = mlockv.size() > 4 ? mlockv[4] : "";
- check_modes(this->c);
- this->RestoreTopic();
- }
+ if (cm != NULL)
+ this->SetMLock(cm, set, param, setter, created);
}
+
+ this->Shrink("db_mlock");
}
/** Check if a mode is mlocked
diff --git a/src/servers.cpp b/src/servers.cpp
index 763fed707..c57dda680 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -51,8 +51,44 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A
/* Check to be sure this isn't a juped server */
if (Me == this->UplinkServer && !this->HasFlag(SERVER_JUPED))
{
- /* Bring in our pseudo-clients */
- introduce_user("");
+ /* Load MLock from the database now that we know what modes exist */
+ for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
+ it->second->LoadMLock();
+
+ ircdproto->SendBOB();
+
+ for (unsigned i = 0; i < Me->GetLinks().size(); ++i)
+ {
+ Server *s = Me->GetLinks()[i];
+
+ if (s->HasFlag(SERVER_JUPED))
+ ircdproto->SendServer(s);
+ }
+
+ /* We make the bots go online */
+ for (Anope::insensitive_map<User *>::iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ {
+ User *u = it->second;
+
+ ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
+
+ BotInfo *bi = findbot(u->nick);
+ if (bi)
+ {
+ XLine x(bi->nick, "Reserved for services");
+ ircdproto->SendSQLine(NULL, &x);
+ }
+ }
+
+ for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
+ {
+ Channel *c = it->second;
+ if (c->users.empty())
+ ircdproto->SendChannel(c);
+ else
+ for (CUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit)
+ ircdproto->SendJoin((*cit)->user, c, (*cit)->Status);
+ }
}
}
}
@@ -210,15 +246,47 @@ void Server::Sync(bool SyncLinks)
if (this->GetUplink() && this->GetUplink() == Me)
{
+ for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
+ {
+ ChannelInfo *ci = it->second;
+ if (ci->HasFlag(CI_PERSIST))
+ {
+ bool created = false;
+ if (!ci->c)
+ {
+ ci->c = new Channel(ci->name, ci->time_registered);
+ created = true;
+ }
+ if (ModeManager::FindChannelModeByName(CMODE_PERM) != NULL)
+ {
+ ci->c->SetMode(NULL, CMODE_PERM);
+ if (created)
+ ircdproto->SendChannel(ci->c);
+ }
+ else
+ {
+ if (!ci->bi)
+ ci->WhoSends()->Assign(NULL, ci);
+ if (ci->c->FindUser(ci->bi) == NULL)
+ ci->bi->Join(ci->c);
+ }
+ }
+ }
+
FOREACH_MOD(I_OnPreUplinkSync, OnPreUplinkSync(this));
+
ircdproto->SendEOB();
Me->Sync(false);
FOREACH_MOD(I_OnUplinkSync, OnUplinkSync(this));
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
- if (it->second->ci)
- it->second->ci->RestoreTopic();
+ {
+ Channel *c = it->second;
+ check_modes(c);
+ if (c->ci)
+ c->ci->RestoreTopic();
+ }
}
}