]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/utils.cpp
Remove now needless User::ForceNickChange()
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / utils.cpp
index 0372172f5ae2e7c4b5d363e94f1a22c2c8fcf4ca..d6dccba14b2e481e2416f4ed45740e5fd3366294 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;
@@ -130,7 +128,7 @@ TreeServer* SpanningTreeUtilities::FindServerID(const std::string &id)
 SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C)
        : Creator(C), TreeRoot(NULL)
 {
-       ServerInstance->Timers->AddTimer(&RefreshTimer);
+       ServerInstance->Timers.AddTimer(&RefreshTimer);
 }
 
 CullResult SpanningTreeUtilities::cull()
@@ -163,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();
        }
@@ -180,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;
@@ -210,10 +207,18 @@ 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);
+       TreeSocket* sock = ts->GetSocket();
+       if (sock)
+               sock->WriteLine(params);
+}
+
 void SpanningTreeUtilities::RefreshIPCache()
 {
        ValidIPs.clear();
@@ -227,8 +232,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);
@@ -257,7 +261,6 @@ void SpanningTreeUtilities::ReadConfiguration()
        HideULines = security->getBool("hideulines");
        AnnounceTSChange = options->getBool("announcets");
        AllowOptCommon = options->getBool("allowmismatch");
-       ChallengeResponse = !security->getBool("disablehmac");
        quiet_bursts = ServerInstance->Config->ConfValue("performance")->getBool("quietbursts");
        PingWarnTime = options->getInt("pingwarning");
        PingFreq = options->getInt("serverpingfreq");
@@ -277,7 +280,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"));
@@ -295,8 +302,8 @@ void SpanningTreeUtilities::ReadConfiguration()
                if (L->Name.find('.') == std::string::npos)
                        throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it must contain at least one '.' character");
 
-               if (L->Name.length() > 64)
-                       throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it is longer than 64 characters");
+               if (L->Name.length() > ServerInstance->Config->Limits.MaxHost)
+                       throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it is longer than " + ConvToStr(ServerInstance->Config->Limits.MaxHost) + " characters");
 
                if (L->RecvPass.empty())
                        throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', recvpass not defined");
@@ -346,6 +353,9 @@ void SpanningTreeUtilities::ReadConfiguration()
                AutoconnectBlocks.push_back(A);
        }
 
+       for (server_hash::const_iterator i = serverlist.begin(); i != serverlist.end(); ++i)
+               i->second->CheckULine();
+
        RefreshIPCache();
 }
 
@@ -354,7 +364,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;
                }