summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-08-12 12:46:11 -0400
committerAdam <Adam@anope.org>2011-08-12 12:46:11 -0400
commitf3d7d4ee3799513eee820d6c79d4e925fc47760e (patch)
tree583e40fcb17d66a523493b9edf4ef5c5ed321fa1 /src
parentfeee50e6959171123773417caab73ecad3af824b (diff)
Track when our clients are introduced or not
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp11
-rw-r--r--src/init.cpp2
-rw-r--r--src/main.cpp5
-rw-r--r--src/protocol.cpp1
-rw-r--r--src/send.cpp10
-rw-r--r--src/servers.cpp1
6 files changed, 26 insertions, 4 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index e94691b05..3e9af64d5 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -20,6 +20,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
this->chancount = 0;
this->lastmsg = this->created = Anope::CurTime;
+ this->introduced = false;
BotListByNick[this->nick] = this;
if (!this->uid.empty())
@@ -28,15 +29,16 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
// If we're synchronised with the uplink already, send the bot.
if (Me && Me->IsSynced())
{
+ Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : (ircd ? ircd->pseudoclient_mode : "");
+ if (!tmodes.empty())
+ this->SetModesInternal(tmodes.c_str());
+
ircdproto->SendClientIntroduction(this);
+ this->introduced = true;
XLine x(this->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
}
- Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : (ircd ? ircd->pseudoclient_mode : "");
- if (!tmodes.empty())
- this->SetModesInternal(tmodes.c_str());
-
if (Config)
for (unsigned i = 0; i < Config->LogInfos.size(); ++i)
{
@@ -70,6 +72,7 @@ BotInfo::~BotInfo()
if (Me && Me->IsSynced())
{
ircdproto->SendQuit(this, "");
+ this->introduced = false;
XLine x(this->nick);
ircdproto->SendSQLineDel(&x);
}
diff --git a/src/init.cpp b/src/init.cpp
index 0a218f099..49d9759a8 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -32,6 +32,8 @@ void introduce_user(const Anope::string &user)
BotInfo *bi = findbot(u->nick);
if (bi)
{
+ bi->introduced = true;
+
XLine x(bi->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
diff --git a/src/main.cpp b/src/main.cpp
index df3d217dd..401431683 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -127,8 +127,13 @@ class UplinkSocket : public ConnectionSocket
User *u = it->second;
if (u->server == Me)
+ {
/* Don't use quitmsg here, it may contain information you don't want people to see */
ircdproto->SendQuit(u, "Shutting down");
+ BotInfo *bi = findbot(u->nick);
+ if (bi != NULL)
+ bi->introduced = false;
+ }
}
ircdproto->SendSquit(Config->ServerName, quitmsg);
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 1c2ef4d7d..8517c73b6 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -331,6 +331,7 @@ bool IRCdMessage::OnKill(const Anope::string &source, const std::vector<Anope::s
/* Recover if someone kills us. */
if (u->server == Me && (bi = dynamic_cast<BotInfo *>(u)))
{
+ bi->introduced = false;
introduce_user(bi->nick);
bi->RejoinAll();
}
diff --git a/src/send.cpp b/src/send.cpp
index c7a0608f8..28c1ca08c 100644
--- a/src/send.cpp
+++ b/src/send.cpp
@@ -39,6 +39,16 @@ void send_cmd(const Anope::string &source, const char *fmt, ...)
return;
}
+ if (!source.empty() && source.find(".") == Anope::string::npos)
+ {
+ BotInfo *bi = findbot(source);
+ if (bi != NULL && bi->introduced == false)
+ {
+ Log(LOG_DEBUG) << "Attempted to send \"" << source << " " << buf << "\" with source not introduced";
+ return;
+ }
+ }
+
if (!source.empty())
{
UplinkSock->Write(":%s %s", source.c_str(), buf);
diff --git a/src/servers.cpp b/src/servers.cpp
index e63311eef..d1e20e515 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -82,6 +82,7 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A
BotInfo *bi = findbot(u->nick);
if (bi)
{
+ bi->introduced = true;
XLine x(bi->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
}