]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/utils.cpp
Merge branch 'insp20' into master.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / utils.cpp
index 6de47de94604b7ef99d626b7550ef91f2306e344..cde627e21af47aa26b4be649d911a307b71f1e21 100644 (file)
@@ -33,7 +33,7 @@ SpanningTreeUtilities* Utils = NULL;
 
 ModResult ModuleSpanningTree::OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
 {
-       if (from->bind_tag->getString("type") != "servers")
+       if (!stdalgo::string::equalsci(from->bind_tag->getString("type"), "servers"))
                return MOD_RES_PASSTHRU;
 
        std::string incomingip = client->addr();
@@ -118,7 +118,7 @@ CullResult SpanningTreeUtilities::cull()
                sock->Close();
        }
 
-       for(std::map<TreeSocket*, std::pair<std::string, int> >::iterator i = timeoutlist.begin(); i != timeoutlist.end(); ++i)
+       for(TimeoutList::iterator i = timeoutlist.begin(); i != timeoutlist.end(); ++i)
        {
                TreeSocket* s = i->first;
                s->Close();
@@ -229,13 +229,10 @@ void SpanningTreeUtilities::ReadConfiguration()
        AnnounceTSChange = options->getBool("announcets");
        AllowOptCommon = options->getBool("allowmismatch");
        quiet_bursts = ServerInstance->Config->ConfValue("performance")->getBool("quietbursts");
-       PingWarnTime = options->getInt("pingwarning");
-       PingFreq = options->getInt("serverpingfreq");
+       PingWarnTime = options->getDuration("pingwarning", 15);
+       PingFreq = options->getDuration("serverpingfreq", 60, 1);
 
-       if (PingFreq == 0)
-               PingFreq = 60;
-
-       if (PingWarnTime < 0 || PingWarnTime > PingFreq - 1)
+       if (PingWarnTime >= PingFreq)
                PingWarnTime = 0;
 
        AutoconnectBlocks.clear();
@@ -253,7 +250,7 @@ void SpanningTreeUtilities::ReadConfiguration()
                        L->AllowMasks.push_back(s);
 
                L->IPAddr = tag->getString("ipaddr");
-               L->Port = tag->getInt("port");
+               L->Port = tag->getUInt("port", 0);
                L->SendPass = tag->getString("sendpass", tag->getString("password"));
                L->RecvPass = tag->getString("recvpass", tag->getString("password"));
                L->Fingerprint = tag->getString("fingerprint");
@@ -267,31 +264,31 @@ void SpanningTreeUtilities::ReadConfiguration()
                        throw ModuleException("Invalid configuration, found a link tag without a name!" + (!L->IPAddr.empty() ? " IP address: "+L->IPAddr : ""));
 
                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");
+                       throw ModuleException("The link name '"+L->Name+"' is invalid as it must contain at least one '.' character");
 
                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");
+                       throw ModuleException("The link name '"+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");
+                       throw ModuleException("Invalid configuration for server '"+L->Name+"', recvpass not defined");
 
                if (L->SendPass.empty())
-                       throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', sendpass not defined");
+                       throw ModuleException("Invalid configuration for server '"+L->Name+"', sendpass not defined");
 
                if ((L->SendPass.find(' ') != std::string::npos) || (L->RecvPass.find(' ') != std::string::npos))
-                       throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that contains a space character which is invalid");
+                       throw ModuleException("Link block '" + L->Name + "' has a password set that contains a space character which is invalid");
 
                if ((L->SendPass[0] == ':') || (L->RecvPass[0] == ':'))
-                       throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that begins with a colon (:) which is invalid");
+                       throw ModuleException("Link block '" + L->Name + "' has a password set that begins with a colon (:) which is invalid");
 
                if (L->IPAddr.empty())
                {
                        L->IPAddr = "*";
-                       ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + assign(L->Name) + "' has no IP defined! This will allow any IP to connect as this server, and MAY not be what you want.");
+                       ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + L->Name + "' has no IP defined! This will allow any IP to connect as this server, and MAY not be what you want.");
                }
 
                if (!L->Port)
-                       ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + assign(L->Name) + "' has no port defined, you will not be able to /connect it.");
+                       ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Configuration warning: Link block '" + L->Name + "' has no port defined, you will not be able to /connect it.");
 
                L->Fingerprint.erase(std::remove(L->Fingerprint.begin(), L->Fingerprint.end(), ':'), L->Fingerprint.end());
                LinkBlocks.push_back(L);
@@ -331,7 +328,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(), rfc_case_insensitive_map))
+               if (InspIRCd::Match(x->Name, name, ascii_case_insensitive_map))
                {
                        return x;
                }