]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add snomask +s +L - remote link notices.
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 31 Oct 2008 15:23:21 +0000 (15:23 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 31 Oct 2008 15:23:21 +0000 (15:23 +0000)
Can be a useful distinction for bigger networks or networks with more distinction on what people can and cannot see.
This also makes RemoteMessage more match it's docs and removes useless redundancy.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10759 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/resolvers.cpp
src/modules/m_spanningtree/treesocket1.cpp
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_spanningtree/utils.cpp
src/snomasks.cpp

index 42547fbdc8c57bb27c947ebdb991a5c0592eb67a..2d9bc3b83d147aef90a8d1208ce0ee65748b0183 100644 (file)
@@ -247,7 +247,7 @@ void ModuleSpanningTree::ConnectServer(Link* x)
 
        if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name)))
        {
-               RemoteMessage(NULL, "CONNECT: Not connecting to myself.");
+               this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself.");
                return;
        }
 
@@ -281,7 +281,7 @@ void ModuleSpanningTree::ConnectServer(Link* x)
                }
                else
                {
-                       RemoteMessage(NULL, "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
+                       this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
                        if (ServerInstance->SocketCull.find(newsocket) == ServerInstance->SocketCull.end())
                                ServerInstance->SocketCull[newsocket] = newsocket;
                        Utils->DoFailOver(x);
@@ -297,7 +297,7 @@ void ModuleSpanningTree::ConnectServer(Link* x)
                }
                catch (ModuleException& e)
                {
-                       RemoteMessage(NULL, "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason());
+                       this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason());
                        Utils->DoFailOver(x);
                }
        }
@@ -377,24 +377,10 @@ int ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters
        return 1;
 }
 
-/* This method will attempt to get a link message out to as many people as is required.
- * If a user is provided, and that user is local, then the user is sent the message using
- * WriteServ (they are the local initiator of that message). If the user is remote, they are
- * sent that message remotely via PUSH.
- * If the user is NULL, then the notice is sent locally via WriteToSnoMask with snomask 'l',
- * and remotely via SNONOTICE with mask 'l'.
+/* This method will attempt to get a message to a remote user.
  */
 void ModuleSpanningTree::RemoteMessage(User* user, const char* format, ...)
 {
-       /* This could cause an infinite loop, because DoOneToMany() will, on error,
-        * call TreeSocket::OnError(), which in turn will call this function to
-        * notify everyone of the error. So, drop any messages that are generated
-        * during the sending of another message. -Special */
-       static bool SendingRemoteMessage = false;
-       if (SendingRemoteMessage)
-               return;
-       SendingRemoteMessage = true;
-
        char text[MAXBUF];
        va_list argsPtr;
 
@@ -402,20 +388,10 @@ void ModuleSpanningTree::RemoteMessage(User* user, const char* format, ...)
        vsnprintf(text, MAXBUF, format, argsPtr);
        va_end(argsPtr);
 
-       if (!user)
-       {
-               /* No user, target it generically at everyone */
-               ServerInstance->SNO->WriteToSnoMask('l', "%s", text);
-       }
+       if (IS_LOCAL(user))
+               user->WriteServ("NOTICE %s :%s", user->nick.c_str(), text);
        else
-       {
-               if (IS_LOCAL(user))
-                       user->WriteServ("NOTICE %s :%s", user->nick.c_str(), text);
-               else
-                       ServerInstance->PI->SendUserNotice(user, text);
-       }
-
-       SendingRemoteMessage = false;
+               ServerInstance->PI->SendUserNotice(user, text);
 }
 
 int ModuleSpanningTree::HandleConnect(const std::vector<std::string>& parameters, User* user)
index 4a33cd2167f4c5627e67673003d970622a05934e..291a609d6fade26b060d4c411be1b3082e0dbe0b 100644 (file)
@@ -63,7 +63,7 @@ void ServernameResolver::OnLookupComplete(const std::string &result, unsigned in
                else
                {
                        /* Something barfed, show the opers */
-                       Utils->Creator->RemoteMessage(NULL, "CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
+                       ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
                        if (ServerInstance->SocketCull.find(newsocket) == ServerInstance->SocketCull.end())
                                ServerInstance->SocketCull[newsocket] = newsocket;
                        Utils->DoFailOver(&MyLink);
@@ -81,7 +81,7 @@ void ServernameResolver::OnError(ResolverError e, const std::string &errormessag
                ServerInstance->AddResolver(snr, cached);
                return;
        }
-       Utils->Creator->RemoteMessage(NULL, "CONNECT: Error connecting \002%s\002: Unable to resolve hostname - %s", MyLink.Name.c_str(), errormessage.c_str() );
+       ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: Unable to resolve hostname - %s", MyLink.Name.c_str(), errormessage.c_str() );
        Utils->DoFailOver(&MyLink);
 }
 
index 03fd05a3419e8f6db3ffdece250e1d87ce212108..4de0926d6e849d29862bf01e4d7da0366edf6798 100644 (file)
@@ -103,11 +103,11 @@ bool TreeSocket::OnConnected()
                {
                        if (x->Name == this->myhost)
                        {
-                               Utils->Creator->RemoteMessage(NULL,"Connection to \2%s\2[%s] started.", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->GetIP().c_str()));
+                               ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2[%s] started.", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->GetIP().c_str()));
                                if (Hook)
                                {
                                        BufferedSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send();
-                                       Utils->Creator->RemoteMessage(NULL,"Connection to \2%s\2[%s] using transport \2%s\2", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->GetIP().c_str()),
+                                       ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2[%s] using transport \2%s\2", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->GetIP().c_str()),
                                                        x->Hook.c_str());
                                }
                                this->OutboundPass = x->SendPass;
@@ -128,7 +128,7 @@ bool TreeSocket::OnConnected()
         * If that happens the connection hangs here until it's closed. Unlikely
         * and rather harmless.
         */
-       this->Utils->Creator->RemoteMessage(NULL,"Connection to \2%s\2 lost link tag(!)", myhost.c_str());
+       ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2 lost link tag(!)", myhost.c_str());
        return true;
 }
 
@@ -139,26 +139,26 @@ void TreeSocket::OnError(BufferedSocketError e)
        switch (e)
        {
                case I_ERR_CONNECT:
-                       Utils->Creator->RemoteMessage(NULL,"Connection failed: Connection to \002%s\002 refused", myhost.c_str());
+                       ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Connection to \002%s\002 refused", myhost.c_str());
                        MyLink = Utils->FindLink(myhost);
                        if (MyLink)
                                Utils->DoFailOver(MyLink);
                break;
                case I_ERR_SOCKET:
-                       Utils->Creator->RemoteMessage(NULL,"Connection failed: Could not create socket (%s)", strerror(errno));
+                       ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Could not create socket (%s)", strerror(errno));
                break;
                case I_ERR_BIND:
-                       Utils->Creator->RemoteMessage(NULL,"Connection failed: Error binding socket to address or port (%s)", strerror(errno));
+                       ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Error binding socket to address or port (%s)", strerror(errno));
                break;
                case I_ERR_WRITE:
-                       Utils->Creator->RemoteMessage(NULL,"Connection failed: I/O error on connection (%s)", errno ? strerror(errno) : "Connection closed unexpectedly");
+                       ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: I/O error on connection (%s)", errno ? strerror(errno) : "Connection closed unexpectedly");
                break;
                case I_ERR_NOMOREFDS:
-                       Utils->Creator->RemoteMessage(NULL,"Connection failed: Operating system is out of file descriptors!");
+                       ServerInstance->SNO->WriteToSnoMask('l', "Connection failed: Operating system is out of file descriptors!");
                break;
                default:
                        if ((errno) && (errno != EINPROGRESS) && (errno != EAGAIN))
-                               Utils->Creator->RemoteMessage(NULL,"Connection to \002%s\002 failed with OS error: %s", myhost.c_str(), strerror(errno));
+                               ServerInstance->SNO->WriteToSnoMask('l', "Connection to \002%s\002 failed with OS error: %s", myhost.c_str(), strerror(errno));
                break;
        }
 }
@@ -174,7 +174,7 @@ int TreeSocket::OnDisconnect()
 void TreeSocket::SendError(const std::string &errormessage)
 {
        /* Display the error locally as well as sending it remotely */
-       Utils->Creator->RemoteMessage(NULL, "Sent \2ERROR\2 to %s: %s", (this->InboundServerName.empty() ? this->GetIP().c_str() : this->InboundServerName.c_str()), errormessage.c_str());
+       ServerInstance->SNO->WriteToSnoMask('l', "Sent \2ERROR\2 to %s: %s", (this->InboundServerName.empty() ? this->GetIP().c_str() : this->InboundServerName.c_str()), errormessage.c_str());
        this->WriteLine("ERROR :"+errormessage);
        /* One last attempt to make sure the error reaches its target */
        this->FlushWriteBuffer();
@@ -208,6 +208,8 @@ void TreeSocket::SquitServer(std::string &from, TreeServer* Current)
  */
 void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
 {
+       bool LocalSquit = false;
+
        if ((Current) && (Current != Utils->TreeRoot))
        {
                Event rmode((char*)Current->GetName().c_str(), (Module*)Utils->Creator, "lost_server");
@@ -219,11 +221,12 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
                Utils->DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
                if (Current->GetParent() == Utils->TreeRoot)
                {
-                       this->ServerInstance->SNO->WriteToSnoMask('l',"Server \002"+Current->GetName()+"\002 split: "+reason);
+                       this->ServerInstance->SNO->WriteToSnoMask('l', "Server \002"+Current->GetName()+"\002 split: "+reason);
+                       LocalSquit = true;
                }
                else
                {
-                       this->ServerInstance->SNO->WriteToSnoMask('l',"Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
+                       this->ServerInstance->SNO->WriteToSnoMask('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
                }
                num_lost_servers = 0;
                num_lost_users = 0;
@@ -232,7 +235,10 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
                Current->Tidy();
                Current->GetParent()->DelChild(Current);
                delete Current;
-               this->ServerInstance->SNO->WriteToSnoMask('l',"Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
+               if (LocalSquit)
+                       this->ServerInstance->SNO->WriteToSnoMask('l', "Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
+               else
+                       this->ServerInstance->SNO->WriteToSnoMask('L', "Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
        }
        else
                ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Squit from unknown server");
index e27c1d879739abba2f8e42e824edeb611ea15df0..b2766148146b89eb545463e91099361e174d695d 100644 (file)
@@ -625,7 +625,7 @@ void TreeSocket::OnTimeout()
 {
        if (this->LinkState == CONNECTING)
        {
-               Utils->Creator->RemoteMessage(NULL, "CONNECT: Connection to \002%s\002 timed out.", myhost.c_str());
+               this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Connection to \002%s\002 timed out.", myhost.c_str());
                Link* MyLink = Utils->FindLink(myhost);
                if (MyLink)
                        Utils->DoFailOver(MyLink);
@@ -654,10 +654,11 @@ void TreeSocket::OnClose()
 
        if (!quitserver.empty())
        {
-               Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' failed.",quitserver.c_str());
+               this->ServerInstance->SNO->WriteToSnoMask('l', "Connection to '\2%s\2' failed.",quitserver.c_str());
+
                time_t server_uptime = ServerInstance->Time() - this->age;
                if (server_uptime)
-                       Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' was established for %s", quitserver.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
+                               this->ServerInstance->SNO->WriteToSnoMask('l', "Connection to '\2%s\2' was established for %s", quitserver.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
        }
 }
 
index c6c9ae700f2c3a3fa269a88f000d41524e9f0b40..48d829f6f3cc78b943acb4d53ada4b0fecb25574 100644 (file)
@@ -48,7 +48,7 @@ void ServerSocketListener::OnAcceptReady(const std::string &ipconnectedto, int n
 
                if (!found)
                {
-                       Utils->Creator->RemoteMessage(NULL,"Server connection from %s denied (no link blocks with that IP address)", ip);
+                       this->ServerInstance->SNO->WriteToSnoMask('l', "Server connection from %s denied (no link blocks with that IP address)", ip);
                        ServerInstance->SE->Close(newsock);
                        return;
                }
@@ -628,7 +628,7 @@ void SpanningTreeUtilities::DoFailOver(Link* x)
        {
                if (x->FailOver == x->Name)
                {
-                       Creator->RemoteMessage(NULL,"FAILOVER: Some muppet configured the failover for server \002%s\002 to point at itself. Not following it!", x->Name.c_str());
+                       this->ServerInstance->SNO->WriteToSnoMask('l', "FAILOVER: Some muppet configured the failover for server \002%s\002 to point at itself. Not following it!", x->Name.c_str());
                        return;
                }
                Link* TryThisOne = this->FindLink(x->FailOver.c_str());
@@ -641,13 +641,13 @@ void SpanningTreeUtilities::DoFailOver(Link* x)
                        }
                        else
                        {
-                               Creator->RemoteMessage(NULL,"FAILOVER: Trying failover link for \002%s\002: \002%s\002...", x->Name.c_str(), TryThisOne->Name.c_str());
+                               this->ServerInstance->SNO->WriteToSnoMask('l', "FAILOVER: Trying failover link for \002%s\002: \002%s\002...", x->Name.c_str(), TryThisOne->Name.c_str());
                                Creator->ConnectServer(TryThisOne);
                        }
                }
                else
                {
-                       Creator->RemoteMessage(NULL,"FAILOVER: Invalid failover server specified for server \002%s\002, will not follow!", x->Name.c_str());
+                       this->ServerInstance->SNO->WriteToSnoMask('l', "FAILOVER: Invalid failover server specified for server \002%s\002, will not follow!", x->Name.c_str());
                }
        }
 }
index 5f04931f991cb3335e7d4a7dbe3f678ec2ad45ce..85e1ead789d9015dc6b45a2c10bcceb57e66c94f 100644 (file)
@@ -99,6 +99,7 @@ void SnomaskManager::SetupDefaults()
        this->EnableSnomask('k',"KILL");                        /* Kill notices */
        this->EnableSnomask('K',"REMOTEKILL");          /* Remote kill notices */
        this->EnableSnomask('l',"LINK");                        /* Link notices */
+       this->EnableSnomask('L',"REMOTELINK");                  /* Link notices */
        this->EnableSnomask('o',"OPER");                        /* Oper up/down notices */
        this->EnableSnomask('A',"ANNOUNCEMENT");        /* formerly WriteOpers() - generic notices to all opers */
        this->EnableSnomask('d',"DEBUG");                       /* Debug notices */