]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Fix for bug #134 reported by mixx941: When user connects to ircd with no usermodes...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index 3f515ff846e4bf9c7451f5a18fefd8f80cdc5de7..335624ec5d4e68780f05a0d5d3f13c28d73f4e6f 100644 (file)
 
 using namespace std;
 
-#include <stdio.h>
-#include <vector>
-#include <deque>
-#include "globals.h"
-#include "inspircd_config.h"
-#include "hash_map.h"
 #include "configreader.h"
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include "commands.h"
 #include "commands/cmd_whois.h"
 #include "commands/cmd_stats.h"
 #include "socket.h"
-
 #include "inspircd.h"
 #include "wildcard.h"
-#include "inspstring.h"
-#include "hashcomp.h"
 #include "xline.h"
-#include "typedefs.h"
 #include "cull_list.h"
 #include "aes.h"
 
@@ -1705,7 +1694,9 @@ class TreeSocket : public InspSocket
                /* This used to have a pretty craq'y loop doing the same thing,
                 * now we just let the STL do the hard work (more efficiently)
                 */
-               params[5] = params[5].substr(params[5].find_first_not_of('+'));
+               std::string::size_type pos_after_plus = params[5].find_first_not_of('+');
+               if (pos_after_plus != std::string::npos)
+                       params[5] = params[5].substr(pos_after_plus);
                
                const char* tempnick = params[1].c_str();
                ServerInstance->Log(DEBUG,"Introduce client %s!%s@%s",tempnick,params[4].c_str(),params[2].c_str());
@@ -3588,53 +3579,60 @@ void ReadConfiguration(bool rebind)
                L.HiddenFromStats = Conf->ReadFlag("link","hidden",j);
                L.NextConnectTime = time(NULL) + L.AutoConnect;
                /* Bugfix by brain, do not allow people to enter bad configurations */
-               if ((L.IPAddr != "") && (L.RecvPass != "") && (L.SendPass != "") && (L.Name != "") && (L.Port))
+               if (L.Name != ServerInstance->Config->ServerName)
                {
-                       ValidIPs.push_back(L.IPAddr);
+                       if ((L.IPAddr != "") && (L.RecvPass != "") && (L.SendPass != "") && (L.Name != "") && (L.Port))
+                       {
+                               ValidIPs.push_back(L.IPAddr);
 
-                       if (Allow.length())
-                               ValidIPs.push_back(Allow);
+                               if (Allow.length())
+                                       ValidIPs.push_back(Allow);
+
+                               /* Needs resolving */
+                               insp_inaddr binip;
+                               if (insp_aton(L.IPAddr.c_str(), &binip) < 1)
+                               {
+                                       try
+                                       {
+                                               SecurityIPResolver* sr = new SecurityIPResolver(ServerInstance, L.IPAddr, L);
+                                               ServerInstance->AddResolver(sr);
+                                       }
+                                       catch (ModuleException& e)
+                                       {
+                                               ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
+                                       }
+                               }
 
-                       /* Needs resolving */
-                       insp_inaddr binip;
-                       if (insp_aton(L.IPAddr.c_str(), &binip) < 1)
+                               LinkBlocks.push_back(L);
+                               ServerInstance->Log(DEBUG,"m_spanningtree: Read server %s with host %s:%d",L.Name.c_str(),L.IPAddr.c_str(),L.Port);
+                       }
+                       else
                        {
-                               try
+                               if (L.IPAddr == "")
+                               {
+                                       ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', IP address not defined!",L.Name.c_str());
+                               }
+                               else if (L.RecvPass == "")
+                               {
+                                       ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', recvpass not defined!",L.Name.c_str());
+                               }
+                               else if (L.SendPass == "")
+                               {
+                                       ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', sendpass not defined!",L.Name.c_str());
+                               }
+                               else if (L.Name == "")
                                {
-                                       SecurityIPResolver* sr = new SecurityIPResolver(ServerInstance, L.IPAddr, L);
-                                       ServerInstance->AddResolver(sr);
+                                       ServerInstance->Log(DEFAULT,"Invalid configuration, link tag without a name!");
                                }
-                               catch (ModuleException& e)
+                               else if (!L.Port)
                                {
-                                       ServerInstance->Log(DEBUG,"Error in resolver: %s",e.GetReason());
+                                       ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', no port specified!",L.Name.c_str());
                                }
                        }
-
-                       LinkBlocks.push_back(L);
-                       ServerInstance->Log(DEBUG,"m_spanningtree: Read server %s with host %s:%d",L.Name.c_str(),L.IPAddr.c_str(),L.Port);
                }
                else
                {
-                       if (L.IPAddr == "")
-                       {
-                               ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', IP address not defined!",L.Name.c_str());
-                       }
-                       else if (L.RecvPass == "")
-                       {
-                               ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', recvpass not defined!",L.Name.c_str());
-                       }
-                       else if (L.SendPass == "")
-                       {
-                               ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', sendpass not defined!",L.Name.c_str());
-                       }
-                       else if (L.Name == "")
-                       {
-                               ServerInstance->Log(DEFAULT,"Invalid configuration, link tag without a name!");
-                       }
-                       else if (!L.Port)
-                       {
-                               ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', no port specified!",L.Name.c_str());
-                       }
+                       ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', link tag has the same server name as the local server!",L.Name.c_str());
                }
        }
        DELETE(Conf);