]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/utils.cpp
m_spanningtree Remove remains of the KeepNickTS workaround
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / utils.cpp
index 40db1339c5ecd38044b89396129cbc27e864ffb8..de96b073d65450959183212fcdc21c1c9dfb5570 100644 (file)
@@ -93,9 +93,7 @@ TreeServer* SpanningTreeUtilities::BestRouteTo(const std::string &ServerName)
                User *u = ServerInstance->FindNick(ServerName);
                if (u)
                {
-                       Found = FindServer(u->server);
-                       if (Found)
-                               return Found->GetRoute();
+                       return TreeServer::Get(u)->GetRoute();
                }
 
                return NULL;
@@ -131,8 +129,6 @@ SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C)
        : Creator(C), TreeRoot(NULL)
 {
        ServerInstance->Timers->AddTimer(&RefreshTimer);
-
-       this->ReadConfiguration();
 }
 
 CullResult SpanningTreeUtilities::cull()
@@ -165,7 +161,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet
        unsigned int minrank = 0;
        if (status)
        {
-               ModeHandler* mh = ServerInstance->Modes->FindPrefix(status);
+               PrefixMode* mh = ServerInstance->Modes->FindPrefix(status);
                if (mh)
                        minrank = mh->GetPrefixRank();
        }
@@ -182,9 +178,8 @@ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet
 
                if (exempt_list.find(i->first) == exempt_list.end())
                {
-                       TreeServer* best = this->BestRouteTo(i->first->server);
-                       if (best)
-                               list.insert(best->GetSocket());
+                       TreeServer* best = TreeServer::Get(i->first);
+                       list.insert(best->GetSocket());
                }
        }
        return;
@@ -212,10 +207,16 @@ bool SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, const std::stri
        if (!Route)
                return false;
 
-       Route->GetSocket()->WriteLine(params);
+       DoOneToOne(params, Route);
        return true;
 }
 
+void SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, Server* server)
+{
+       TreeServer* ts = static_cast<TreeServer*>(server);
+       ts->GetSocket()->WriteLine(params);
+}
+
 void SpanningTreeUtilities::RefreshIPCache()
 {
        ValidIPs.clear();
@@ -229,8 +230,7 @@ void SpanningTreeUtilities::RefreshIPCache()
                        continue;
                }
 
-               if (L->AllowMask.length())
-                       ValidIPs.push_back(L->AllowMask);
+               ValidIPs.insert(ValidIPs.end(), L->AllowMasks.begin(), L->AllowMasks.end());
 
                irc::sockets::sockaddrs dummy;
                bool ipvalid = irc::sockets::aptosa(L->IPAddr, L->Port, dummy);
@@ -279,7 +279,11 @@ void SpanningTreeUtilities::ReadConfiguration()
                reference<Link> L = new Link(tag);
                std::string linkname = tag->getString("name");
                L->Name = linkname.c_str();
-               L->AllowMask = tag->getString("allowmask");
+
+               irc::spacesepstream sep = tag->getString("allowmask");
+               for (std::string s; sep.GetToken(s);)
+                       L->AllowMasks.push_back(s);
+
                L->IPAddr = tag->getString("ipaddr");
                L->Port = tag->getInt("port");
                L->SendPass = tag->getString("sendpass", tag->getString("password"));
@@ -348,6 +352,9 @@ void SpanningTreeUtilities::ReadConfiguration()
                AutoconnectBlocks.push_back(A);
        }
 
+       for (server_hash::const_iterator i = serverlist.begin(); i != serverlist.end(); ++i)
+               i->second->CheckULine();
+
        RefreshIPCache();
 }
 
@@ -356,7 +363,7 @@ Link* SpanningTreeUtilities::FindLink(const std::string& name)
        for (std::vector<reference<Link> >::iterator i = LinkBlocks.begin(); i != LinkBlocks.end(); ++i)
        {
                Link* x = *i;
-               if (InspIRCd::Match(x->Name.c_str(), name.c_str()))
+               if (InspIRCd::Match(x->Name.c_str(), name.c_str(), rfc_case_insensitive_map))
                {
                        return x;
                }
@@ -367,9 +374,10 @@ Link* SpanningTreeUtilities::FindLink(const std::string& name)
 void SpanningTreeUtilities::SendChannelMessage(const std::string& prefix, Channel* target, const std::string& text, char status, const CUList& exempt_list, const char* message_type, TreeSocket* omit)
 {
        CmdBuilder msg(prefix, message_type);
-       if (status == 0)
-               status = ' ';
-       msg.push(status).push_raw(target->name).push_last(text);
+       msg.push_raw(' ');
+       if (status != 0)
+               msg.push_raw(status);
+       msg.push_raw(target->name).push_last(text);
 
        TreeSocketSet list;
        this->GetListOfServersForChannel(target, list, status, exempt_list);