X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Ftreesocket1.cpp;h=2198d6208c1f6927f2e386eae57dd25543047710;hb=4a12fc9d4bfb77fc2fc05c1052c66294e3774649;hp=8dd62a1e9ec5818cda29bbc6918813953006f1e5;hpb=8a7ed312cfcd47a39ac07b146b4aaf5f9ca1c0e2;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 8dd62a1e9..2198d6208 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -31,10 +31,10 @@ #include "treesocket.h" #include "commands.h" -/** Because most of the I/O gubbins are encapsulated within - * BufferedSocket, we just call the superclass constructor for - * most of the action, and append a few of our own values - * to it. +/** Constructor for outgoing connections. + * Because most of the I/O gubbins are encapsulated within + * BufferedSocket, we just call DoConnect() for most of the action, + * and only do minor initialization tasks ourselves. */ TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const std::string& ipaddr) : linkID(assign(link->Name)), LinkState(CONNECTING), MyRoot(NULL), proto_version(0) @@ -50,9 +50,7 @@ TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const std::string& ipaddr) SendCapabilities(1); } -/** When a listening socket gives us a new file descriptor, - * we must associate it with a socket without creating a new - * connection. This constructor is used for this purpose. +/** Constructor for incoming connections */ TreeSocket::TreeSocket(int newfd, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) : BufferedSocket(newfd) @@ -69,11 +67,6 @@ TreeSocket::TreeSocket(int newfd, ListenSocket* via, irc::sockets::sockaddrs* cl Utils->timeoutlist[this] = std::pair(linkID, 30); } -ServerState TreeSocket::GetLinkState() -{ - return this->LinkState; -} - void TreeSocket::CleanNegotiationInfo() { // connect is good, reset the autoconnect block (if used) @@ -97,10 +90,10 @@ TreeSocket::~TreeSocket() } /** When an outbound connection finishes connecting, we receive - * this event, and must send our SERVER string to the other + * this event, and must do CAPAB negotiation with the other * side. If the other side is happy, as outlined in the server * to server docs on the inspircd.org site, the other side - * will then send back its own server string. + * will then send back its own SERVER string eventually. */ void TreeSocket::OnConnected() { @@ -128,6 +121,7 @@ void TreeSocket::OnError(BufferedSocketError e) ServerInstance->SNO->WriteGlobalSno('l', "Connection to '\002%s\002' failed with error: %s", linkID.c_str(), getError().c_str()); LinkState = DYING; + Close(); } void TreeSocket::SendError(const std::string &errormessage) @@ -153,6 +147,8 @@ CmdResult CommandSQuit::HandleServer(TreeServer* server, std::vectorGetParent(); } + else if (quitting->GetParent() != server) + throw ProtocolException("Attempted to SQUIT a non-directly connected server or the parent"); server->SQuitChild(quitting, params[1]); @@ -174,7 +170,7 @@ void TreeSocket::OnDataReady() { std::string::size_type rline = line.find('\r'); if (rline != std::string::npos) - line = line.substr(0,rline); + line.erase(rline); if (line.find('\0') != std::string::npos) { SendError("Read null character from socket");