]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
Replaced vsnprintf with VAFORMAT pretty much everywhere.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index a5785f20cf75a1aaaa67ec3c05c40faeb5d2135c..244180b2f4e5875797d5fa3ca67a8aa1d0dce7da 100644 (file)
@@ -27,7 +27,6 @@
 #include "socket.h"
 #include "xline.h"
 
-#include "cachetimer.h"
 #include "resolvers.h"
 #include "main.h"
 #include "utils.h"
 #include "protocolinterface.h"
 
 ModuleSpanningTree::ModuleSpanningTree()
+       : commands(NULL), DNS(this, "DNS"), Utils(NULL)
 {
-       Utils = new SpanningTreeUtilities(this);
-       commands = new SpanningTreeCommands(this);
-       RefreshTimer = NULL;
 }
 
 SpanningTreeCommands::SpanningTreeCommands(ModuleSpanningTree* module)
@@ -54,6 +51,8 @@ SpanningTreeCommands::SpanningTreeCommands(ModuleSpanningTree* module)
 
 void ModuleSpanningTree::init()
 {
+       Utils = new SpanningTreeUtilities(this);
+       commands = new SpanningTreeCommands(this);
        ServerInstance->Modules->AddService(commands->rconnect);
        ServerInstance->Modules->AddService(commands->rsquit);
        ServerInstance->Modules->AddService(commands->svsjoin);
@@ -70,8 +69,6 @@ void ModuleSpanningTree::init()
        ServerInstance->Modules->AddService(commands->fhost);
        ServerInstance->Modules->AddService(commands->fident);
        ServerInstance->Modules->AddService(commands->fname);
-       RefreshTimer = new CacheRefreshTimer(Utils);
-       ServerInstance->Timers->AddTimer(RefreshTimer);
 
        Implementation eventlist[] =
        {
@@ -196,8 +193,7 @@ restart:
                                        // ... if we can find a proper route to them
                                        if (tsock)
                                        {
-                                               tsock->WriteLine(":" + ServerInstance->Config->GetSID() + " PING " +
-                                                               ServerInstance->Config->GetSID() + " " + s->GetID());
+                                               tsock->WriteLine(":" + ServerInstance->Config->GetSID() + " PING " + s->GetID());
                                                s->LastPingMsec = ts;
                                        }
                                }
@@ -273,8 +269,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
                return;
        }
 
-       QueryType start_type = DNS_QUERY_A;
-       start_type = DNS_QUERY_AAAA;
+       DNS::QueryType start_type = DNS::QUERY_AAAA;
        if (strchr(x->IPAddr.c_str(),':'))
        {
                in6_addr n;
@@ -304,16 +299,20 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
                        ServerInstance->GlobalCulls.AddItem(newsocket);
                }
        }
+       else if (!DNS)
+       {
+               ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: Hostname given and m_dns.so is not loaded, unable to resolve.", x->Name.c_str());
+       }
        else
        {
+               ServernameResolver* snr = new ServernameResolver(Utils, *DNS, x->IPAddr, x, start_type, y);
                try
                {
-                       bool cached = false;
-                       ServernameResolver* snr = new ServernameResolver(Utils, x->IPAddr, x, cached, start_type, y);
-                       ServerInstance->AddResolver(snr, cached);
+                       DNS->Process(snr);
                }
-               catch (ModuleException& e)
+               catch (DNS::Exception& e)
                {
+                       delete snr;
                        ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason());
                        ConnectServer(y, false);
                }
@@ -381,15 +380,11 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& para
  */
 void ModuleSpanningTree::RemoteMessage(User* user, const char* format, ...)
 {
-       char text[MAXBUF];
-       va_list argsPtr;
-
-       va_start(argsPtr, format);
-       vsnprintf(text, MAXBUF, format, argsPtr);
-       va_end(argsPtr);
+       std::string text;
+       VAFORMAT(text, format, format);
 
        if (IS_LOCAL(user))
-               user->WriteServ("NOTICE %s :%s", user->nick.c_str(), text);
+               user->WriteNotice(text);
        else
                ServerInstance->PI->SendUserNotice(user, text);
 }
@@ -538,7 +533,8 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user)
        if (user->IsOper())
        {
                params.clear();
-               params.push_back(user->oper->name);
+               params.push_back(":");
+               params[0].append(user->oper->name);
                Utils->DoOneToMany(user->uuid,"OPERTYPE",params);
        }
 
@@ -732,7 +728,7 @@ void ModuleSpanningTree::OnRehash(User* user)
                std::string msg = "Error in configuration: ";
                msg.append(e.GetReason());
                ServerInstance->SNO->WriteToSnoMask('l', msg);
-               if (!IS_LOCAL(user))
+               if (user && !IS_LOCAL(user))
                        ServerInstance->PI->SendSNONotice("L", msg);
        }
 }
@@ -776,7 +772,8 @@ void ModuleSpanningTree::OnOper(User* user, const std::string &opertype)
        if (user->registered != REG_ALL || !IS_LOCAL(user))
                return;
        parameterlist params;
-       params.push_back(opertype);
+       params.push_back(":");
+       params[0].append(opertype);
        Utils->DoOneToMany(user->uuid,"OPERTYPE",params);
 }
 
@@ -907,7 +904,6 @@ void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, con
 CullResult ModuleSpanningTree::cull()
 {
        Utils->cull();
-       ServerInstance->Timers->DelTimer(RefreshTimer);
        return this->Module::cull();
 }