]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/connection.cpp
ConfigReader fixes to cope with tab characters (why didnt we notice this before?)
[user/henk/code/inspircd.git] / src / connection.cpp
index 3572952451aafd10d63ff3ff2fdc0405cd138ccb..ec3007a8c0c0ad4e6b54fc6d990773d924db6a16 100644 (file)
 
 using namespace std;
 
+
 extern std::vector<Module*> modules;
 extern std::vector<ircd_module*> factory;
 
 extern int MODCOUNT;
 
+
+
 connection::connection()
 {
        fd = 0;
@@ -166,12 +169,12 @@ bool connection::BeginLink(char* targethost, int port, char* password, char* ser
        char connect[MAXBUF];
        
        ircd_connector connector;
-       ircd_connector *cn = this->FindServer(servername);
+       ircd_connector *cn = this->FindHost(servername);
 
 
        if (cn)
        {
-               WriteOpers("CONNECT aborted: Server %s already exists from %s",servername,ServerName);
+               WriteOpers("CONNECT aborted: Server %s already exists",servername);
                return false;
        }
 
@@ -345,19 +348,23 @@ bool connection::SendPacket(char *message, const char* host)
                if (cn->GetState() == STATE_DISCONNECTED)
                {
                        log(DEBUG,"Main route to %s is down, seeking alternative",host);
-                       // this route is down, we must re-route the packet through an available point in the mesh.
-                       for (int k = 0; k < this->connectors.size(); k++)
+                       // fix: can only route one hop to avoid a loop
+                       if (strncat(message,"R ",2))
                        {
-                               // search for another point in the mesh which can 'reach' where we want to go
-                               for (int m = 0; m < this->connectors[k].routes.size(); m++)
+                               // this route is down, we must re-route the packet through an available point in the mesh.
+                               for (int k = 0; k < this->connectors.size(); k++)
                                {
-                                       if (!strcasecmp(this->connectors[k].routes[m].c_str(),host))
+                                       // search for another point in the mesh which can 'reach' where we want to go
+                                       for (int m = 0; m < this->connectors[k].routes.size(); m++)
                                        {
-                                               log(DEBUG,"Found alternative route for packet: %s",this->connectors[k].GetServerName().c_str());
-                                               char buffer[MAXBUF];
-                                               snprintf(buffer,MAXBUF,"R %s %s",host,message);
-                                               this->SendPacket(buffer,this->connectors[k].GetServerName().c_str());
-                                               return true;
+                                               if (!strcasecmp(this->connectors[k].routes[m].c_str(),host))
+                                               {
+                                                       log(DEBUG,"Found alternative route for packet: %s",this->connectors[k].GetServerName().c_str());
+                                                       char buffer[MAXBUF];
+                                                       snprintf(buffer,MAXBUF,"R %s %s",host,message);
+                                                       this->SendPacket(buffer,this->connectors[k].GetServerName().c_str());
+                                                       return true;
+                                               }
                                        }
                                }
                        }