]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Remove some debug (im on a crusade to make debug mode useful, but at the same time...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index e960948ac280813b952c4280519dc3128426b2d4..1a9affaf1545e0e20b7b44ae0e87b972bada9f80 100644 (file)
@@ -167,6 +167,11 @@ class SpanningTreeUtilities
        /** Holds the data from the <link> tags in the conf
         */
        std::vector<Link> LinkBlocks;
+       /** Holds a bitmask of queued xline types waiting to be applied.
+        * Will be a mask containing values APPLY_GLINES, APPLY_KLINES,
+        * APPLY_QLINES and APPLY_ZLINES.
+        */
+       int lines_to_apply;
 
        hookmodules hooks;
        std::vector<std::string> hooknames;
@@ -1904,7 +1909,7 @@ class TreeSocket : public InspSocket
                {
                        _new->modes[(*v)-65] = 1;
                        /* For each mode thats set, increase counter */
-                       ModeHandler* mh = Instance->Modes->FindMode((*v)-65, MODETYPE_USER);
+                       ModeHandler* mh = Instance->Modes->FindMode(*v, MODETYPE_USER);
                        if (mh)
                                mh->ChangeCount(1);
                }
@@ -2367,6 +2372,7 @@ class TreeSocket : public InspSocket
                if (u)
                {
                        u->modes[UM_OPERATOR] = 1;
+                       this->Instance->all_opers.push_back(u);
                        strlcpy(u->oper,opertype.c_str(),NICKMAX-1);
                        Utils->DoOneToAllButSender(u->nick,"OPERTYPE",params,u->server);
                        this->Instance->SNO->WriteToSnoMask('o',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server, u->nick,u->ident,u->host,irc::Spacify(opertype.c_str()));
@@ -2634,15 +2640,22 @@ class TreeSocket : public InspSocket
 
                bool propogate = false;
 
+               if (!this->bursting)
+                       Utils->lines_to_apply = 0;
+
                switch (*(params[0].c_str()))
                {
                        case 'Z':
                                propogate = Instance->XLines->add_zline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
                                Instance->XLines->zline_set_creation_time(params[1].c_str(), atoi(params[3].c_str()));
+                               if (propogate)
+                                       Utils->lines_to_apply |= APPLY_ZLINES;
                        break;
                        case 'Q':
                                propogate = Instance->XLines->add_qline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
                                Instance->XLines->qline_set_creation_time(params[1].c_str(), atoi(params[3].c_str()));
+                               if (propogate)
+                                       Utils->lines_to_apply |= APPLY_QLINES;
                        break;
                        case 'E':
                                propogate = Instance->XLines->add_eline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
@@ -2651,9 +2664,13 @@ class TreeSocket : public InspSocket
                        case 'G':
                                propogate = Instance->XLines->add_gline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
                                Instance->XLines->gline_set_creation_time(params[1].c_str(), atoi(params[3].c_str()));
+                               if (propogate)
+                                       Utils->lines_to_apply |= APPLY_GLINES;
                        break;
                        case 'K':
                                propogate = Instance->XLines->add_kline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
+                               if (propogate)
+                                       Utils->lines_to_apply |= APPLY_KLINES;
                        break;
                        default:
                                /* Just in case... */
@@ -2678,8 +2695,9 @@ class TreeSocket : public InspSocket
                }
                if (!this->bursting)
                {
-                       Instance->Log(DEBUG,"Applying lines...");
-                       Instance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+                       Instance->Log(DEBUG,"Applying lines with mask %d...", Utils->lines_to_apply);
+                       Instance->XLines->apply_lines(Utils->lines_to_apply);
+                       Utils->lines_to_apply = 0;
                }
                return true;
        }
@@ -3367,7 +3385,9 @@ class TreeSocket : public InspSocket
                                        if (this->bursting)
                                        {
                                                this->bursting = false;
-                                               Instance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+                                               Instance->Log(DEBUG,"Applying lines with mask %d...", Utils->lines_to_apply);
+                                               Instance->XLines->apply_lines(Utils->lines_to_apply);
+                                               Utils->lines_to_apply = 0;
                                        }
                                        if (prefix == "")
                                        {
@@ -3385,7 +3405,9 @@ class TreeSocket : public InspSocket
                                        if (this->bursting)
                                        {
                                                this->bursting = false;
-                                               Instance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+                                               Instance->Log(DEBUG,"Applying lines with mask %d...", Utils->lines_to_apply);
+                                               Instance->XLines->apply_lines(Utils->lines_to_apply);
+                                               Utils->lines_to_apply = 0;
                                        }
                                        if (prefix == "")
                                        {
@@ -3512,7 +3534,9 @@ class TreeSocket : public InspSocket
                                else if (command == "ENDBURST")
                                {
                                        this->bursting = false;
-                                       Instance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+                                       Instance->Log(DEBUG,"Applying lines with mask %d...", Utils->lines_to_apply);
+                                       Instance->XLines->apply_lines(Utils->lines_to_apply);
+                                       Utils->lines_to_apply = 0;
                                        std::string sourceserv = this->myhost;
                                        if (this->InboundServerName != "")
                                        {
@@ -3713,12 +3737,12 @@ class ServernameResolver : public Resolver
        Link MyLink;
        SpanningTreeUtilities* Utils;
  public: 
-       ServernameResolver(Module* me, SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &hostname, Link x) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, me), MyLink(x), Utils(Util)
+       ServernameResolver(Module* me, SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), MyLink(x), Utils(Util)
        {
                /* Nothing in here, folks */
        }
 
-       void OnLookupComplete(const std::string &result)
+       void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
        {
                /* Initiate the connection, now that we have an IP to use.
                 * Passing a hostname directly to InspSocket causes it to
@@ -3763,11 +3787,11 @@ class SecurityIPResolver : public Resolver
        Link MyLink;
        SpanningTreeUtilities* Utils;
  public:
-       SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, me), MyLink(x), Utils(U)
+       SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), MyLink(x), Utils(U)
        {
        }
 
-       void OnLookupComplete(const std::string &result)
+       void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached)
        {
                ServerInstance->Log(DEBUG,"Security IP cache: Adding IP address '%s' for Link '%s'",result.c_str(),MyLink.Name.c_str());
                Utils->ValidIPs.push_back(result);
@@ -3783,6 +3807,8 @@ SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningT
 {
        Bindings.clear();
 
+       lines_to_apply = 0;
+
        this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc);
 
        modulelist* ml = ServerInstance->FindInterface("InspSocketHook");
@@ -4121,8 +4147,9 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
                                {
                                        try
                                        {
-                                               SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L);
-                                               ServerInstance->AddResolver(sr);
+                                               bool cached;
+                                               SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L, cached);
+                                               ServerInstance->AddResolver(sr, cached);
                                        }
                                        catch (ModuleException& e)
                                        {
@@ -4652,8 +4679,9 @@ class ModuleSpanningTree : public Module
                {
                        try
                        {
-                               ServernameResolver* snr = new ServernameResolver((Module*)this, Utils, ServerInstance,x->IPAddr, *x);
-                               ServerInstance->AddResolver(snr);
+                               bool cached;
+                               ServernameResolver* snr = new ServernameResolver((Module*)this, Utils, ServerInstance,x->IPAddr, *x, cached);
+                               ServerInstance->AddResolver(snr, cached);
                        }
                        catch (ModuleException& e)
                        {
@@ -5155,6 +5183,7 @@ class ModuleSpanningTree : public Module
                        }
                }
                Utils->ReadConfiguration(false);
+               InitializeDisabledCommands(ServerInstance->Config->DisabledCommands, ServerInstance);
        }
 
        // note: the protocol does not allow direct umode +o except
@@ -5456,15 +5485,13 @@ class ModuleSpanningTree : public Module
        }
 };
 
-TimeSyncTimer::TimeSyncTimer(InspIRCd *Inst, ModuleSpanningTree *Mod) : InspTimer(43200, Inst->Time()), Instance(Inst), Module(Mod)
+TimeSyncTimer::TimeSyncTimer(InspIRCd *Inst, ModuleSpanningTree *Mod) : InspTimer(43200, Inst->Time(), true), Instance(Inst), Module(Mod)
 {
 }
 
 void TimeSyncTimer::Tick(time_t TIME)
 {
        Module->BroadcastTimeSync();
-       Module->SyncTimer = new TimeSyncTimer(Instance, Module);
-       Instance->Timers->AddTimer(Module->SyncTimer);
 }
 
 void SpanningTreeUtilities::DoFailOver(Link* x)