]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
m_spanningtree Do pointer comparison before deleting one of the pointers in TreeSocke...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index ffc466a82758d9c8e64774e785713a744bb0bbb0..d702ab4a25c9d93e497a5283c945de4c5dc3cc85 100644 (file)
@@ -38,6 +38,7 @@
 #include "protocolinterface.h"
 
 ModuleSpanningTree::ModuleSpanningTree()
+       : KeepNickTS(false)
 {
        Utils = new SpanningTreeUtilities(this);
        commands = new SpanningTreeCommands(this);
@@ -83,7 +84,7 @@ void ModuleSpanningTree::init()
        ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
 
        delete ServerInstance->PI;
-       ServerInstance->PI = new SpanningTreeProtocolInterface(this, Utils);
+       ServerInstance->PI = new SpanningTreeProtocolInterface(Utils);
        loopCall = false;
 
        // update our local user count
@@ -265,14 +266,13 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
 {
        bool ipvalid = true;
 
-       if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name)))
+       if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name), rfc_case_insensitive_map))
        {
                ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself.");
                return;
        }
 
-       QueryType start_type = DNS_QUERY_A;
-       start_type = DNS_QUERY_AAAA;
+       QueryType start_type = DNS_QUERY_AAAA;
        if (strchr(x->IPAddr.c_str(),':'))
        {
                in6_addr n;
@@ -396,9 +396,9 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& para
        for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++)
        {
                Link* x = *i;
-               if (InspIRCd::Match(x->Name.c_str(),parameters[0]))
+               if (InspIRCd::Match(x->Name.c_str(),parameters[0], rfc_case_insensitive_map))
                {
-                       if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name)))
+                       if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name), rfc_case_insensitive_map))
                        {
                                RemoteMessage(user, "*** CONNECT: Server \002%s\002 is ME, not connecting.",x->Name.c_str());
                                return MOD_RES_DENY;
@@ -646,14 +646,13 @@ void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos)
                return;
 
        parameterlist params;
-       params.push_back(gecos);
+       params.push_back(":" + gecos);
        Utils->DoOneToMany(user->uuid,"FNAME",params);
 }
 
 void ModuleSpanningTree::OnChangeIdent(User* user, const std::string &ident)
 {
-       // only occurs for local clients
-       if (user->registered != REG_ALL)
+       if ((user->registered != REG_ALL) || (!IS_LOCAL(user)))
                return;
 
        parameterlist params;
@@ -706,11 +705,12 @@ void ModuleSpanningTree::OnUserPostNick(User* user, const std::string &oldnick)
 
                /** IMPORTANT: We don't update the TS if the oldnick is just a case change of the newnick!
                 */
-               if (irc::string(user->nick.c_str()) != assign(oldnick))
+               if ((irc::string(user->nick.c_str()) != assign(oldnick)) && (!this->KeepNickTS))
                        user->age = ServerInstance->Time();
 
                params.push_back(ConvToStr(user->age));
                Utils->DoOneToMany(user->uuid,"NICK",params);
+               this->KeepNickTS = false;
        }
        else if (!loopCall && user->nick == user->uuid)
        {
@@ -783,7 +783,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);
        }
 }
@@ -817,6 +817,13 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod)
                        sock->Close();
                }
        }
+
+       for (SpanningTreeUtilities::TimeoutList::const_iterator i = Utils->timeoutlist.begin(); i != Utils->timeoutlist.end(); ++i)
+       {
+               TreeSocket* sock = i->first;
+               if (sock->GetIOHook() == mod)
+                       sock->Close();
+       }
 }
 
 // note: the protocol does not allow direct umode +o except
@@ -911,7 +918,7 @@ ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg)
                parameterlist params;
                if (!awaymsg.empty())
                {
-                       params.push_back(ConvToStr(user->awaytime));
+                       params.push_back(ConvToStr(ServerInstance->Time()));
                        params.push_back(":" + awaymsg);
                }
                Utils->DoOneToMany(user->uuid, "AWAY", params);