diff options
author | Adam <Adam@anope.org> | 2012-02-19 20:54:55 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-02-19 20:54:55 -0500 |
commit | b84e0804636d3868684c6ec2670207e7ae1cadeb (patch) | |
tree | 059be9a9da7b530970bc44f2c8eee5f61497a82e /src/main.cpp | |
parent | 0ba58d7d0eea4e2a0e0d18a66880f84af6fea60e (diff) |
Made our message sources actual clients/servers, and put in a few more default messages for very standard things (KICK etc)
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/src/main.cpp b/src/main.cpp index 55f185057..1d0a3e963 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -178,50 +178,71 @@ void UplinkSocket::OnError(const Anope::string &error) Log(LOG_TERMINAL) << "Unable to connect to server " << Config->Uplinks[CurrentUplink]->host << ":" << Config->Uplinks[CurrentUplink]->port << (!error.empty() ? (": " + error) : ""); } -UplinkSocket::Message::Message() +UplinkSocket::Message::Message() : server(NULL), user(NULL) { } -UplinkSocket::Message::Message(const Anope::string &s) : source(s) +UplinkSocket::Message::Message(const Server *s) : server(s), user(NULL) { } +UplinkSocket::Message::Message(const User *u) : server(NULL), user(u) +{ + if (!u) + server = Me; +} + UplinkSocket::Message::~Message() { - if (!UplinkSock) - { - if (!this->source.empty()) - Log(LOG_DEBUG) << "Attempted to send \"" << this->source << " " << this->buffer.str() << "\" with UplinkSock NULL"; - else - Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" with UplinkSock NULL"; - return; - } + Anope::string message_source = ""; - if (this->source == Me->GetName()) + if (this->server != NULL) { + if (this->server != Me && !this->server->HasFlag(SERVER_JUPED)) + { + Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << this->server->GetName() << " who is not from me?"; + return; + } + if (ircd->ts6) - this->source = Me->GetSID(); + message_source = this->server->GetSID(); + else + message_source = this->server->GetName(); } - else if (!this->source.empty() && this->source != Me->GetSID()) + else if (this->user != NULL) { - BotInfo *bi = findbot(this->source); - if (bi != NULL) + if (this->user->server != Me && !this->user->server->HasFlag(SERVER_JUPED)) { - if (bi->introduced == false) - { - Log(LOG_DEBUG) << "Attempted to send \"" << this->source << " " << this->buffer.str() << "\" with source not introduced"; - return; - } + Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << this->user->nick << " who is not from me?"; + return; + } - if (ircd->ts6) - this->source = bi->GetUID(); + BotInfo *bi = findbot(this->user->nick); + if (bi != NULL && bi->introduced == false) + { + Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" from " << bi->nick << " when not introduced"; + return; } + + if (ircd->ts6) + message_source = this->user->GetUID(); + else + message_source = this->user->nick; + } + + if (!UplinkSock) + { + if (!message_source.empty()) + Log(LOG_DEBUG) << "Attempted to send \"" << message_source << " " << this->buffer.str() << "\" with UplinkSock NULL"; + else + Log(LOG_DEBUG) << "Attempted to send \"" << this->buffer.str() << "\" with UplinkSock NULL"; + return; } - if (!this->source.empty()) + if (!message_source.empty()) { - UplinkSock->Write(":" + this->source + " " + this->buffer.str()); - Log(LOG_RAWIO) << "Sent: :" << this->source << " " << this->buffer.str(); + UplinkSock->Write(":" + message_source + " " + this->buffer.str()); + Log(LOG_RAWIO) << "Sent: :" << message_source << " " << this->buffer.str(); } else { |