]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
Merge pull request #590 from SaberUK/master+module-logging
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index 8c5439fbb239314f480a7b7c40121e067fd491fd..3c82d9de0204a5f9843053403cd140120930f717 100644 (file)
@@ -21,8 +21,6 @@
  */
 
 
-/* $ModDesc: Provides a spanning tree server link protocol */
-
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
@@ -52,6 +50,8 @@ SpanningTreeCommands::SpanningTreeCommands(ModuleSpanningTree* module)
 
 void ModuleSpanningTree::init()
 {
+       ServerInstance->SNO->EnableSnomask('l', "LINK");
+
        Utils = new SpanningTreeUtilities(this);
        commands = new SpanningTreeCommands(this);
        ServerInstance->Modules->AddService(commands->rconnect);
@@ -118,8 +118,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
        else if ((Current->Hidden) && (!user->IsOper()))
                return;
 
-       std::string servername = Current->GetName();
-       user->WriteNumeric(364, "%s %s %s :%d %s",      user->nick.c_str(), servername.c_str(),
+       user->WriteNumeric(364, "%s %s %s :%d %s",      user->nick.c_str(), Current->GetName().c_str(),
                        (Utils->FlatLinks && (!user->IsOper())) ? ServerInstance->Config->ServerName.c_str() : Parent.c_str(),
                        (Utils->FlatLinks && (!user->IsOper())) ? 0 : hops,
                        Current->GetDesc().c_str());
@@ -215,8 +214,7 @@ restart:
                        if ((Utils->PingWarnTime) && (!s->Warned) && (curtime >= s->NextPingTime() - (Utils->PingFreq - Utils->PingWarnTime)) && (!s->AnsweredLastPing()))
                        {
                                /* The server hasnt responded, send a warning to opers */
-                               std::string servername = s->GetName();
-                               ServerInstance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not responded to PING for %d seconds, high latency.", servername.c_str(), Utils->PingWarnTime);
+                               ServerInstance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not responded to PING for %d seconds, high latency.", s->GetName().c_str(), Utils->PingWarnTime);
                                s->Warned = true;
                        }
                }
@@ -412,8 +410,7 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& para
                        }
                        else
                        {
-                               std::string servername = CheckDupe->GetParent()->GetName();
-                               RemoteMessage(user, "*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002", x->Name.c_str(), servername.c_str());
+                               RemoteMessage(user, "*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002", x->Name.c_str(), CheckDupe->GetParent()->GetName().c_str());
                                return MOD_RES_DENY;
                        }
                }
@@ -672,7 +669,7 @@ void ModuleSpanningTree::OnPreRehash(User* user, const std::string &parameter)
        if (loopCall)
                return; // Don't generate a REHASH here if we're in the middle of processing a message that generated this one
 
-       ServerInstance->Logs->Log("remoterehash", LOG_DEBUG, "called with param %s", parameter.c_str());
+       ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "OnPreRehash called with param %s", parameter.c_str());
 
        // Send out to other servers
        if (!parameter.empty() && parameter[0] != '-')
@@ -812,9 +809,7 @@ ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg)
 void ModuleSpanningTree::ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const parameterlist &modeline, const std::vector<TranslateType> &translate)
 {
        TreeSocket* s = (TreeSocket*)opaque;
-       std::string output_text;
-
-       ServerInstance->Parser->TranslateUIDs(translate, modeline, output_text);
+       std::string output_text = CommandParser::TranslateUIDs(translate, modeline);
 
        if (target)
        {
@@ -846,7 +841,8 @@ void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, con
 
 CullResult ModuleSpanningTree::cull()
 {
-       Utils->cull();
+       if (Utils)
+               Utils->cull();
        return this->Module::cull();
 }