diff options
author | Adam <Adam@anope.org> | 2011-11-25 00:44:31 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-11-25 00:44:31 -0500 |
commit | cef3eb78dfd2ea20e0a482d040cc99902fdb4b2a (patch) | |
tree | d9e964ac19137e87a6fb97d25dda9be6487c2aa9 /src/main.cpp | |
parent | 12d0a7302f76fe21c54ffcead286fc31e870b817 (diff) |
Remove send_cmd and replace it with a stringstream
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 03920424a..ed31febf8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -125,7 +125,7 @@ UplinkSocket::~UplinkSocket() } } - ircdproto->SendSquit(Config->ServerName, quitmsg); + ircdproto->SendSquit(Me, quitmsg); this->ProcessWrite(); // Write out the last bit } @@ -172,6 +172,58 @@ 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(const Anope::string &s) : source(s) +{ +} + +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; + } + + if (this->source == Me->GetName()) + { + if (ircd->ts6) + this->source = Me->GetSID(); + } + else if (!this->source.empty() && this->source != Me->GetSID()) + { + BotInfo *bi = findbot(this->source); + if (bi != NULL) + { + if (bi->introduced == false) + { + Log(LOG_DEBUG) << "Attempted to send \"" << this->source << " " << this->buffer.str() << "\" with source not introduced"; + return; + } + + if (ircd->ts6) + this->source = bi->GetUID(); + } + } + + if (!this->source.empty()) + { + UplinkSock->Write(":" + this->source + " " + this->buffer.str()); + Log(LOG_RAWIO) << "Sent: :" << this->source << " " << this->buffer.str(); + } + else + { + UplinkSock->Write(this->buffer.str()); + Log(LOG_RAWIO) << "Sent: " << this->buffer.str(); + } +} + static void Connect() { if (static_cast<unsigned>(++CurrentUplink) >= Config->Uplinks.size()) |