]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/utils.cpp
Stability fixes, some DELETEs here that dont belong any more.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / utils.cpp
index 08f9e67eb193de7f3081bb360c12e0fb5ae80fbc..9d4fbf41a3c19c4d2c7555d2fbccc30e4abf9e3a 100644 (file)
@@ -190,7 +190,6 @@ SpanningTreeUtilities::~SpanningTreeUtilities()
        {
                ServerInstance->SE->DelFd(Bindings[i]);
                Bindings[i]->Close();
-               DELETE(Bindings[i]);
        }
        while (TreeRoot->ChildCount())
        {
@@ -200,7 +199,6 @@ SpanningTreeUtilities::~SpanningTreeUtilities()
                        TreeSocket* sock = child_server->GetSocket();
                        ServerInstance->SE->DelFd(sock);
                        sock->Close();
-                       DELETE(sock);
                }
        }
        delete TreeRoot;
@@ -409,7 +407,7 @@ void SpanningTreeUtilities::RefreshIPCache()
        ValidIPs.clear();
        for (std::vector<Link>::iterator L = LinkBlocks.begin(); L != LinkBlocks.end(); L++)
        {
-               if ((L->IPAddr != "") && (L->RecvPass != "") && (L->SendPass != "") && (L->Name != "") && (L->Port))
+               if ((!L->IPAddr.empty()) && (!L->RecvPass.empty()) && (!L->SendPass.empty()) && (!L->Name.empty()) && (L->Port))
                {
                        ValidIPs.push_back(L->IPAddr);
 
@@ -428,16 +426,12 @@ void SpanningTreeUtilities::RefreshIPCache()
                                        ipvalid = false;
                        }
                        else
+#endif
                        {
                                in_addr n;
                                if (inet_aton(L->IPAddr.c_str(),&n) < 1)
                                        ipvalid = false;
                        }
-#else
-                       in_addr n;
-                       if (inet_aton(L->IPAddr.c_str(),&n) < 1)
-                               ipvalid = false;
-#endif
                        if (!ipvalid)
                        {
                                try
@@ -459,7 +453,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
        ConfigReader* Conf = new ConfigReader(ServerInstance);
        if (rebind)
        {
-               for (int j =0; j < Conf->Enumerate("bind"); j++)
+               for (int j = 0; j < Conf->Enumerate("bind"); j++)
                {
                        std::string Type = Conf->ReadValue("bind","type",j);
                        std::string IP = Conf->ReadValue("bind","address",j);
@@ -472,7 +466,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
                                while ((portno = portrange.GetToken()))
                                {
                                        if (IP == "*")
-                                               IP = "";
+                                               IP.clear();
 
                                        if ((!transport.empty()) && (hooks.find(transport.c_str()) ==  hooks.end()))
                                        {
@@ -490,7 +484,6 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
                                        {
                                                ServerInstance->Log(DEFAULT,"m_spanningtree: Warning: Failed to bind server port: %s:%d: %s",IP.c_str(), portno, strerror(errno));
                                                listener->Close();
-                                               DELETE(listener);
                                        }
                                }
                        }
@@ -510,7 +503,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
 
        LinkBlocks.clear();
        ValidIPs.clear();
-       for (int j =0; j < Conf->Enumerate("link"); j++)
+       for (int j = 0; j < Conf->Enumerate("link"); j++)
        {
                Link L;
                std::string Allow = Conf->ReadValue("link", "allowmask", j);
@@ -522,7 +515,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
                L.SendPass = Conf->ReadValue("link", "sendpass", j);
                L.RecvPass = Conf->ReadValue("link", "recvpass", j);
                L.AutoConnect = Conf->ReadInteger("link", "autoconnect", j, true);
-               L.HiddenFromStats = Conf->ReadFlag("link", "hidden", j);
+               L.HiddenFromStats = Conf->ReadFlag("link", "statshidden", j);
                L.Timeout = Conf->ReadInteger("link", "timeout", j, true);
                L.Hook = Conf->ReadValue("link", "transport", j);
                L.Bind = Conf->ReadValue("link", "bind", j);
@@ -540,7 +533,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
                /* Bugfix by brain, do not allow people to enter bad configurations */
                if (L.Name != ServerInstance->Config->ServerName)
                {
-                       if ((L.IPAddr != "") && (L.RecvPass != "") && (L.SendPass != "") && (L.Name != "") && (L.Port))
+                       if ((!L.IPAddr.empty()) && (!L.RecvPass.empty()) && (!L.SendPass.empty()) && (!L.Name.empty()) && (L.Port))
                        {
                                ValidIPs.push_back(L.IPAddr);
 
@@ -587,19 +580,19 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
                        }
                        else
                        {
-                               if (L.IPAddr == "")
+                               if (L.IPAddr.empty())
                                {
                                        ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', IP address not defined!",L.Name.c_str());
                                }
-                               else if (L.RecvPass == "")
+                               else if (L.RecvPass.empty())
                                {
                                        ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', recvpass not defined!",L.Name.c_str());
                                }
-                               else if (L.SendPass == "")
+                               else if (L.SendPass.empty())
                                {
                                        ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', sendpass not defined!",L.Name.c_str());
                                }
-                               else if (L.Name == "")
+                               else if (L.Name.empty())
                                {
                                        ServerInstance->Log(DEFAULT,"Invalid configuration, link tag without a name!");
                                }