]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/treesocket1.cpp
Clean up duplicated link snomask messages on errors
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treesocket1.cpp
index 962b63984ce62b35865e9ebab0110242c2b10a63..fcd6871e1a06533b182221512070eb729ffdb7b6 100644 (file)
@@ -72,19 +72,19 @@ found:
 TreeSocket::TreeSocket(SpanningTreeUtilities* Util, int newfd, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
        : BufferedSocket(newfd), Utils(Util)
 {
-       int dummy;
-       irc::sockets::satoap(client, IP, dummy);
+       IP = client->addr();
        age = ServerInstance->Time();
        LinkState = WAIT_AUTH_1;
        capab_phase = 0;
        proto_version = 0;
+       myhost = "inbound from " + IP;
 
        FOREACH_MOD(I_OnHookIO, OnHookIO(this, via));
        if (GetIOHook())
                GetIOHook()->OnStreamSocketAccept(this, client, server);
        SendCapabilities(1);
 
-       Utils->timeoutlist[this] = std::pair<std::string, int>("inbound from " + IP, 30);
+       Utils->timeoutlist[this] = std::pair<std::string, int>(myhost, 30);
 }
 
 ServerState TreeSocket::GetLinkState()
@@ -155,8 +155,6 @@ void TreeSocket::SendError(const std::string &errormessage)
 {
        WriteLine("ERROR :"+errormessage);
        SetError(errormessage);
-       /* Display the error locally as well as sending it remotely */
-       ServerInstance->SNO->WriteGlobalSno('l', "Sent \2ERROR\2 to %s: %s", (this->InboundServerName.empty() ? this->IP.c_str() : this->InboundServerName.c_str()), errormessage.c_str());
 }
 
 /** This function forces this server to quit, removing this server
@@ -214,11 +212,12 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
                SquitServer(from, Current);
                Current->Tidy();
                Current->GetParent()->DelChild(Current);
+               Current->cull();
                delete Current;
                if (LocalSquit)
-                       ServerInstance->SNO->WriteGlobalSno('l', "Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
+                       ServerInstance->SNO->WriteToSnoMask('l', "Netsplit complete, lost \002%d\002 user%s on \002%d\002 server%s.", num_lost_users, num_lost_users != 1 ? "s" : "", num_lost_servers, num_lost_servers != 1 ? "s" : "");
                else
-                       ServerInstance->SNO->WriteGlobalSno('L', "Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
+                       ServerInstance->SNO->WriteToSnoMask('L', "Netsplit complete, lost \002%d\002 user%s on \002%d\002 server%s.", num_lost_users, num_lost_users != 1 ? "s" : "", num_lost_servers, num_lost_servers != 1 ? "s" : "");
        }
        else
                ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Squit from unknown server");