]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fixed some SQUIT stuff
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 16 Apr 2004 15:23:47 +0000 (15:23 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 16 Apr 2004 15:23:47 +0000 (15:23 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@621 e03df62e-2008-0410-955e-edbf42e46eb7

include/inspircd.h
src/connection.cpp
src/inspircd.cpp

index f0e92782b96e8f9e6bc973d224e7c6a4a42cd242..36d902fbfa9c8d649d3ee53a5cb6987278c5acb2 100644 (file)
@@ -125,4 +125,5 @@ void NetSendToAllAlive(char* s);
 void NetSendToOne(char* target,char* s);
 void NetSendToAllExcept(const char* target,char* s);
 void NetSendMyRoutingTable();
+void DoSplit(const char* params);
 
index 20695e8732495f702afe13fe27c24fc29c70b3ae..514897ecb4f435011e94b7ffd14225b4554b50d3 100644 (file)
@@ -364,6 +364,7 @@ bool connection::SendPacket(char *message, const char* host)
                        snprintf(buffer,MAXBUF,"& %s",host);
                        NetSendToAllExcept(host,buffer);
                        log(DEBUG,"There are no routes to %s, we're gonna boot the server off!",host);
+                       DoSplit(host);
                        return false;
                }
 
index 55a38a35315579ea199b095dab1a43192c7d9c13..0aadf62ea11b0ada85fb3177636fca3ccfdfe4a4 100644 (file)
@@ -6560,6 +6560,53 @@ void handle_dollar(char token,char* params,serverrec* source,serverrec* reply, c
        log(DEBUG,"Warning! routing table received from nonexistent server!");
 }
 
+
+void DoSplit(const char* params)
+{
+       bool go_again = true;
+       while (go_again)
+       {
+               go_again = false;
+               for (int i = 0; i < 32; i++)
+               {
+                       if (me[i] != NULL)
+                       {
+                               for (vector<ircd_connector>::iterator j = me[i]->connectors.begin(); j != me[i]->connectors.end(); j++)
+                               {
+                                       if (!strcasecmp(j->GetServerName().c_str(),params))
+                                       {
+                                               j->routes.clear();
+                                               j->CloseConnection();
+                                               me[i]->connectors.erase(j);
+                                               go_again = true;
+                                               break;
+                                       }
+                               }
+                       }
+               }
+       }
+       log(DEBUG,"Removed server. Will remove clients...");
+       // iterate through the userlist and remove all users on this server.
+       // because we're dealing with a mesh, we dont have to deal with anything
+       // "down-route" from this server (nice huh)
+       go_again = true;
+       char reason[MAXBUF];
+       snprintf(reason,MAXBUF,"%s %s",ServerName,params);
+       while (go_again)
+       {
+               go_again = false;
+               for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
+               {
+                       if (!strcasecmp(u->second->server,params))
+                       {
+                               kill_link(u->second,reason);
+                               go_again = true;
+                               break;
+                       }
+               }
+       }
+}
+
 void handle_amp(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
 {
        log(DEBUG,"Netsplit! %s split from mesh, removing!",params);