]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
Send HALFOP= line in CAPAB CAPABILITIES for 1201 compat (anope relies on this)
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index 0c221a9f49e816cd2bab9e6ccad127f02a240536..68367cee0142eb8cb4eebba65a3271c90f9cd240 100644 (file)
@@ -31,6 +31,7 @@ ModuleSpanningTree::ModuleSpanningTree()
 {
        Utils = new SpanningTreeUtilities(this);
        commands = new SpanningTreeCommands(this);
+       RefreshTimer = NULL;
 }
 
 SpanningTreeCommands::SpanningTreeCommands(ModuleSpanningTree* module)
@@ -43,7 +44,6 @@ SpanningTreeCommands::SpanningTreeCommands(ModuleSpanningTree* module)
 
 void ModuleSpanningTree::init()
 {
-       RefreshTimer = new CacheRefreshTimer(Utils);
        ServerInstance->Modules->AddService(commands->rconnect);
        ServerInstance->Modules->AddService(commands->rsquit);
        ServerInstance->Modules->AddService(commands->svsjoin);
@@ -58,6 +58,7 @@ 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[] =
@@ -147,9 +148,16 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime)
         */
        long ts = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000);
 
+restart:
        for (server_hash::iterator i = Utils->serverlist.begin(); i != Utils->serverlist.end(); i++)
        {
                TreeServer *s = i->second;
+               
+               if (s->GetSocket() && s->GetSocket()->GetLinkState() == DYING)
+               {
+                       s->GetSocket()->Close();
+                       goto restart;
+               }
 
                // Fix for bug #792, do not ping servers that are not connected yet!
                // Remote servers have Socket == NULL and local connected servers have
@@ -187,9 +195,8 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime)
                                        if (sock)
                                        {
                                                sock->SendError("Ping timeout");
-                                               sock->Squit(s,"Ping timeout");
                                                sock->Close();
-                                               return;
+                                               goto restart;
                                        }
                                }
                        }
@@ -271,8 +278,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
        if (ipvalid)
        {
                /* Gave a hook, but it wasnt one we know */
-               TreeSocket* newsocket = new TreeSocket(Utils, x->IPAddr, x->Port, x->Timeout ? x->Timeout : 10,
-                       x->Name.c_str(), x->Bind, y, x->Hook);
+               TreeSocket* newsocket = new TreeSocket(Utils, x, y, x->IPAddr);
                if (newsocket->GetFd() > -1)
                {
                        /* Handled automatically on success */
@@ -322,12 +328,16 @@ void ModuleSpanningTree::DoConnectTimeout(time_t curtime)
                std::pair<std::string, int> p = i->second;
                std::map<TreeSocket*, std::pair<std::string, int> >::iterator me = i;
                i++;
-               if (curtime > s->age + p.second)
+               if (s->GetLinkState() == DYING)
+               {
+                       Utils->timeoutlist.erase(me);
+                       s->Close();
+               }
+               else if (curtime > s->age + p.second)
                {
                        ServerInstance->SNO->WriteToSnoMask('l',"CONNECT: Error connecting \002%s\002 (timeout of %d seconds)",p.first.c_str(),p.second);
                        Utils->timeoutlist.erase(me);
                        s->Close();
-                       ServerInstance->GlobalCulls.AddItem(s);
                }
        }
 }
@@ -572,6 +582,13 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user)
        params.push_back(":"+std::string(user->fullname));
        Utils->DoOneToMany(ServerInstance->Config->GetSID(), "UID", params);
 
+       if (IS_OPER(user))
+       {
+               params.clear();
+               params.push_back(user->oper->name);
+               Utils->DoOneToMany(user->uuid,"OPERTYPE",params);
+       }
+
        for(Extensible::ExtensibleStore::const_iterator i = user->GetExtList().begin(); i != user->GetExtList().end(); i++)
        {
                ExtensionItem* item = i->first;
@@ -767,7 +784,6 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod)
                if (sock && sock->GetIOHook() == mod)
                {
                        sock->SendError("SSL module unloaded");
-                       sock->Squit(srv,"SSL module unloaded");
                        sock->Close();
                }
        }
@@ -782,12 +798,11 @@ void ModuleSpanningTree::RedoConfig(Module* mod)
 // locally.
 void ModuleSpanningTree::OnOper(User* user, const std::string &opertype)
 {
-       if (IS_LOCAL(user))
-       {
-               parameterlist params;
-               params.push_back(opertype);
-               Utils->DoOneToMany(user->uuid,"OPERTYPE",params);
-       }
+       if (user->registered != REG_ALL || !IS_LOCAL(user))
+               return;
+       parameterlist params;
+       params.push_back(opertype);
+       Utils->DoOneToMany(user->uuid,"OPERTYPE",params);
 }
 
 void ModuleSpanningTree::OnAddLine(User* user, XLine *x)