aboutsummaryrefslogtreecommitdiffstats
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorGravatar brain2004-04-16 14:16:13 +0000
committerGravatar brain2004-04-16 14:16:13 +0000
commita9682a795a548eee1db19f424f1cb1ef236538dd (patch)
treec6d6416ef03c15f4a1ae20b155e706cd7b2d3316 /src/inspircd.cpp
parentAdded ability to update routing table on the fly if a connection is lost (diff)
downloadinspircd++-a9682a795a548eee1db19f424f1cb1ef236538dd.tar.gz
inspircd++-a9682a795a548eee1db19f424f1cb1ef236538dd.tar.bz2
inspircd++-a9682a795a548eee1db19f424f1cb1ef236538dd.zip
Added some netsplit handling stuff (untested)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@613 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index f178a9f0b..92ebb4771 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -6520,6 +6520,53 @@ void handle_dollar(char token,char* params,serverrec* source,serverrec* reply, c
log(DEBUG,"Warning! routing table received from nonexistent server!");
}
+void handle_amp(char token,char* params,serverrec* source,serverrec* reply, char* udp_host)
+{
+ log(DEBUG,"Netsplit! %s split from mesh, removing!",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 process_restricted_commands(char token,char* params,serverrec* source,serverrec* reply, char* udp_host,char* ipaddr,int port)
{
@@ -6560,6 +6607,11 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve
case '$':
handle_dollar(token,params,source,reply,udp_host);
break;
+ // node unreachable - we cant route to a server, sooooo we slit it off.
+ // servers can generate these for themselves for an squit.
+ case '&':
+ handle_amp(token,params,source,reply,udp_host);
+ break;
// R <server> <data>
// redirect token, send all of <data> along to the given
// server as this server has been found to still have a route to it