diff options
author | Adam <Adam@anope.org> | 2013-07-26 21:40:16 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-07-26 21:40:16 -0400 |
commit | fde83f6564c38635c7bfebd7edb60f30b012189c (patch) | |
tree | f4a56f82280ecb1f3ed3291b44c6afda72a0fce2 /src | |
parent | f0f43cf4264c68d638cd5920877d088c6c278435 (diff) |
Rethink jupe/squit thing somewhat. Workaround for the inspircd rsquit/squit mess
Diffstat (limited to 'src')
-rw-r--r-- | src/bots.cpp | 13 | ||||
-rw-r--r-- | src/config.cpp | 1 | ||||
-rw-r--r-- | src/init.cpp | 21 | ||||
-rw-r--r-- | src/protocol.cpp | 1 | ||||
-rw-r--r-- | src/uplink.cpp | 59 |
5 files changed, 42 insertions, 53 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index b85bd2534..315045b86 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -106,7 +106,7 @@ Serializable* BotInfo::Unserialize(Serializable *obj, Serialize::Data &data) return bi; } -void BotInfo::Up() +void BotInfo::GenerateUID() { if (!this->uid.empty()) throw CoreException("Bot already has a uid?"); @@ -114,17 +114,6 @@ void BotInfo::Up() this->uid = Servers::TS6_UID_Retrieve(); (*BotListByUID)[this->uid] = this; UserListByUID[this->uid] = this; - this->server = Me; - ++this->server->users; -} - -void BotInfo::Down() -{ - BotListByUID->erase(this->uid); - UserListByUID.erase(this->uid); - --this->server->users; - this->server = NULL; - this->uid = ""; } void BotInfo::SetNewNick(const Anope::string &newnick) diff --git a/src/config.cpp b/src/config.cpp index f748383ab..27c3eccdc 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -149,6 +149,7 @@ Conf::Conf() : Block("") {"serverinfo", "name"}, {"serverinfo", "description"}, {"serverinfo", "localhost"}, + {"serverinfo", "id"}, {"serverinfo", "pid"}, {"networkinfo", "nicklen"}, {"networkinfo", "userlen"}, diff --git a/src/init.cpp b/src/init.cpp index e8ee21b19..dbcdea02c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -428,6 +428,15 @@ void Anope::Init(int ac, char **av) /* Write our PID to the PID file. */ write_pidfile(); + /* Create me */ + Configuration::Block *block = Config->GetBlock("serverinfo"); + Me = new Server(NULL, block->Get<const Anope::string>("name"), 0, block->Get<const Anope::string>("description"), block->Get<const Anope::string>("id")); + for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) + { + it->second->server = Me; + ++Me->users; + } + /* Announce ourselves to the logfile. */ Log() << "Anope " << Anope::Version() << " starting up" << (Anope::Debug || Anope::ReadOnly ? " (options:" : "") << (Anope::Debug ? " debug" : "") << (Anope::ReadOnly ? " readonly" : "") << (Anope::Debug || Anope::ReadOnly ? ")" : ""); @@ -437,7 +446,7 @@ void Anope::Init(int ac, char **av) Language::InitLanguages(); /* Initialize random number generator */ - Configuration::Block *block = Config->GetBlock("options"); + block = Config->GetBlock("options"); srand(block->Get<unsigned>("seed")); /* load modules */ @@ -451,6 +460,16 @@ void Anope::Init(int ac, char **av) Log() << "Using IRCd protocol " << protocol->name; + /* Auto assign sid if applicable */ + if (IRCD->RequiresID) + { + Anope::string sid = Servers::TS6_SID_Retrieve(); + if (Me->GetSID() == Me->GetName()) + Me->SetSID(sid); + for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) + it->second->GenerateUID(); + } + /* Load up databases */ Log() << "Loading databases..."; EventReturn MOD_RESULT; diff --git a/src/protocol.cpp b/src/protocol.cpp index 15b39b971..b5ee8da3f 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -264,7 +264,6 @@ void IRCDProto::SendGlobops(const BotInfo *source, const char *fmt, ...) void IRCDProto::SendSquit(Server *s, const Anope::string &message) { UplinkSocket::Message() << "SQUIT " << s->GetSID() << " :" << message; - s->Delete(message); } void IRCDProto::SendNickChange(const User *u, const Anope::string &newnick) diff --git a/src/uplink.cpp b/src/uplink.cpp index 100b58310..d29af3bea 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -61,56 +61,42 @@ void Uplink::Connect() UplinkSocket::UplinkSocket() : Socket(-1, Config->Uplinks[Anope::CurrentUplink].ipv6), ConnectionSocket(), BufferedSocket() { - /* Create me */ - Configuration::Block *block = Config->GetBlock("serverinfo"); - Anope::string id = block->Get<const Anope::string>("id"); - if (id.empty()) - /* Defalt to a valid ts6 sid if this ircd is ts6 */ - id = Servers::TS6_SID_Retrieve(); - Me = new Server(NULL, block->Get<const Anope::string>("name"), 0, block->Get<const Anope::string>("description"), id); - - for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) - { - BotInfo *bi = it->second; - bi->Up(); - } - UplinkSock = this; } UplinkSocket::~UplinkSocket() { - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + if (IRCD && Servers::GetUplink() && Servers::GetUplink()->IsSynced()) { - User *u = it->second; + FOREACH_MOD(OnServerDisconnect, ()); - if (u->server == Me) + for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - /* Don't use quitmsg here, it may contain information you don't want people to see */ - IRCD->SendQuit(u, "Shutting down"); - BotInfo* bi = BotInfo::Find(u->nick); - if (bi != NULL) + User *u = it->second; + + if (u->server == Me) { - bi->introduced = false; - bi->Down(); + /* Don't use quitmsg here, it may contain information you don't want people to see */ + IRCD->SendQuit(u, "Shutting down"); + BotInfo* bi = BotInfo::Find(u->nick); + if (bi != NULL) + bi->introduced = false; } - else - /* Enforcer client or some other non-service bot */ - u->Quit("Shutting down"); } - } - - User::QuitUsers(); - FOREACH_MOD(OnServerDisconnect, ()); + IRCD->SendSquit(Me, Anope::QuitReason); - IRCD->SendSquit(Me, Anope::QuitReason); - Me = NULL; + this->ProcessWrite(); // Write out the last bit + } - this->ProcessWrite(); // Write out the last bit + for (unsigned i = Me->GetLinks().size(); i > 0; --i) + if (!Me->GetLinks()[i - 1]->IsJuped()) + Me->GetLinks()[i - 1]->Delete(Me->GetName() + " " + Me->GetLinks()[i - 1]->GetName()); UplinkSock = NULL; + Me->Unsync(); + if (Anope::AtTerm()) { if (static_cast<unsigned>(Anope::CurrentUplink + 1) == Config->Uplinks.size()) @@ -186,12 +172,7 @@ UplinkSocket::Message::~Message() } else if (this->user != NULL) { - if (this->user->server == NULL) - { - Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << this->user->nick << " who has no server (I'm not introduced?)"; - return; - } - else if (this->user->server != Me && !this->user->server->IsJuped()) + if (this->user->server != Me && !this->user->server->IsJuped()) { Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << this->user->nick << " who is not from me?"; return; |