summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/bots.h3
-rw-r--r--modules/commands/os_dns.cpp2
-rw-r--r--modules/protocol/hybrid.cpp7
-rw-r--r--modules/protocol/inspircd12.cpp8
-rw-r--r--modules/pseudoclients/botserv.cpp2
-rw-r--r--modules/pseudoclients/global.cpp2
-rw-r--r--src/bots.cpp14
-rw-r--r--src/config.cpp1
-rw-r--r--src/init.cpp11
-rw-r--r--src/uplink.cpp53
10 files changed, 52 insertions, 51 deletions
diff --git a/include/bots.h b/include/bots.h
index ef05c11e0..9c2fc60e3 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -58,7 +58,8 @@ class CoreExport BotInfo : public User, public Serializable
void Serialize(Serialize::Data &data) const;
static Serializable* Unserialize(Serializable *obj, Serialize::Data &);
- void GenerateUID();
+ void Up();
+ void Down();
/** Change the nickname for the bot.
* @param newnick The nick to change to
diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp
index c71b1f887..0590bd704 100644
--- a/modules/commands/os_dns.cpp
+++ b/modules/commands/os_dns.cpp
@@ -686,7 +686,7 @@ class ModuleDNS : public Module
void OnNewServer(Server *s) anope_override
{
- if (s == Me || s->IsJuped())
+ if (Me == NULL || s == Me || s->IsJuped())
return;
if (!Me->IsSynced() || this->readd_connected_servers)
{
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp
index 93f4c53c8..41c1a37f1 100644
--- a/modules/protocol/hybrid.cpp
+++ b/modules/protocol/hybrid.cpp
@@ -625,13 +625,6 @@ public:
message_certfp(this)
{
this->AddModes();
-
-
- if (Me->GetSID() == Me->GetName())
- Me->SetSID(Servers::TS6_SID_Retrieve());
-
- for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
- it->second->GenerateUID();
}
void OnUserNickChange(User *u, const Anope::string &) anope_override
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 2e880b631..a28b3c511 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -1323,15 +1323,7 @@ class ProtoInspIRCd : public Module
message_idle(this), message_metadata(this), message_mode(this), message_nick(this), message_opertype(this), message_rsquit(this),
message_setident(this), message_server(this), message_time(this), message_uid(this), message_encap(this)
{
-
-
Servers::Capab.insert("NOQUIT");
-
- if (Me->GetSID() == Me->GetName())
- Me->SetSID(Servers::TS6_SID_Retrieve());
-
- for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
- it->second->GenerateUID();
}
void OnReload(Configuration::Conf *conf) anope_override
diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp
index e8452de13..dac89a2f7 100644
--- a/modules/pseudoclients/botserv.cpp
+++ b/modules/pseudoclients/botserv.cpp
@@ -49,7 +49,7 @@ class BotServCore : public Module
void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) anope_override
{
- if (Me->IsSynced() && ci->c && ci->c->users.size() >= Config->GetModule(this)->Get<unsigned>("minusers"))
+ if (ci->c && ci->c->users.size() >= Config->GetModule(this)->Get<unsigned>("minusers"))
{
ChannelStatus status(Config->GetModule(this)->Get<const Anope::string>("botmodes"));
bi->Join(ci->c, &status);
diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp
index 1500ebb17..9a886c64c 100644
--- a/modules/pseudoclients/global.cpp
+++ b/modules/pseudoclients/global.cpp
@@ -79,7 +79,7 @@ class GlobalCore : public Module, public GlobalService
void OnNewServer(Server *s) anope_override
{
const Anope::string &gl = Config->GetModule(this)->Get<const Anope::string>("globaloncycleup");
- if (!gl.empty() && !Me->IsSynced())
+ if (!gl.empty() && Me && !Me->IsSynced())
s->Notice(Global, gl);
}
diff --git a/src/bots.cpp b/src/bots.cpp
index 0a65393bb..b85bd2534 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -106,13 +106,25 @@ Serializable* BotInfo::Unserialize(Serializable *obj, Serialize::Data &data)
return bi;
}
-void BotInfo::GenerateUID()
+void BotInfo::Up()
{
if (!this->uid.empty())
throw CoreException("Bot already has a uid?");
+
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 27c3eccdc..f748383ab 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -149,7 +149,6 @@ 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 d76a631f5..e8ee21b19 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -428,15 +428,6 @@ 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 ? ")" : "");
@@ -446,7 +437,7 @@ void Anope::Init(int ac, char **av)
Language::InitLanguages();
/* Initialize random number generator */
- block = Config->GetBlock("options");
+ Configuration::Block *block = Config->GetBlock("options");
srand(block->Get<unsigned>("seed"));
/* load modules */
diff --git a/src/uplink.cpp b/src/uplink.cpp
index 282d8be05..100b58310 100644
--- a/src/uplink.cpp
+++ b/src/uplink.cpp
@@ -61,42 +61,55 @@ 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()
{
- if (IRCD && Servers::GetUplink() && Servers::GetUplink()->IsSynced())
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
- FOREACH_MOD(OnServerDisconnect, ());
+ User *u = it->second;
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ if (u->server == Me)
{
- User *u = it->second;
-
- if (u->server == Me)
+ /* 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)
{
- /* 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;
+ bi->introduced = false;
+ bi->Down();
}
+ else
+ /* Enforcer client or some other non-service bot */
+ u->Quit("Shutting down");
}
+ }
- IRCD->SendSquit(Me, Anope::QuitReason);
+ User::QuitUsers();
- this->ProcessWrite(); // Write out the last bit
- }
+ FOREACH_MOD(OnServerDisconnect, ());
- if (Me)
- 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());
+ IRCD->SendSquit(Me, Anope::QuitReason);
+ Me = NULL;
- UplinkSock = NULL;
+ this->ProcessWrite(); // Write out the last bit
- Me->Unsync();
+ UplinkSock = NULL;
if (Anope::AtTerm())
{