1
0
mirror of https://github.com/anope/anope.git synced 2026-07-07 03:23:13 +02:00

Rethink jupe/squit thing somewhat. Workaround for the inspircd rsquit/squit mess

This commit is contained in:
Adam
2013-07-26 21:40:16 -04:00
parent f0f43cf426
commit fde83f6564
11 changed files with 182 additions and 157 deletions
+1 -12
View File
@@ -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)
+1
View File
@@ -149,6 +149,7 @@ Conf::Conf() : Block("")
{"serverinfo", "name"},
{"serverinfo", "description"},
{"serverinfo", "localhost"},
{"serverinfo", "id"},
{"serverinfo", "pid"},
{"networkinfo", "nicklen"},
{"networkinfo", "userlen"},
+20 -1
View File
@@ -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;
-1
View File
@@ -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)
+21 -40
View File
@@ -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");
}
IRCD->SendSquit(Me, Anope::QuitReason);
this->ProcessWrite(); // Write out the last bit
}
User::QuitUsers();
FOREACH_MOD(OnServerDisconnect, ());
IRCD->SendSquit(Me, Anope::QuitReason);
Me = NULL;
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;