From b7849c813319bc12fd9f5b6ae1fe711220694b13 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 11 Apr 2004 01:09:49 +0000 Subject: Added preliminary support for network propogated kicks via the 'k' datagram git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@519 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/InspIRCd.layout | 26 +++++++++++++------------- src/inspircd.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index e5044a666..001dbf33f 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -13,9 +13,9 @@ LeftChar=1 [Editor_1] Open=1 Top=1 -CursorCol=58 -CursorRow=2618 -TopLine=2590 +CursorCol=53 +CursorRow=1768 +TopLine=1725 LeftChar=1 [Editor_2] @@ -67,7 +67,7 @@ TopLine=6 LeftChar=1 [Editor_8] -Open=0 +Open=1 Top=0 CursorCol=1 CursorRow=33 @@ -216,11 +216,11 @@ CursorRow=13 TopLine=23 LeftChar=1 [Editor_27] -Open=0 +Open=1 Top=0 -CursorCol=6 -CursorRow=34 -TopLine=1 +CursorCol=3 +CursorRow=67 +TopLine=34 LeftChar=1 [Editor_28] Open=1 @@ -237,18 +237,18 @@ CursorRow=21 TopLine=1 LeftChar=1 [Editor_30] -Open=0 +Open=1 Top=0 CursorCol=87 CursorRow=21 TopLine=1 LeftChar=4 [Editor_31] -Open=0 +Open=1 Top=0 -CursorCol=32 -CursorRow=33 -TopLine=1 +CursorCol=22 +CursorRow=32 +TopLine=8 LeftChar=1 [Editor_32] Open=0 diff --git a/src/inspircd.cpp b/src/inspircd.cpp index b45debd55..726318a23 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1691,11 +1691,8 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool { if (servers[j] != NULL) { - if (ChanAnyOnThisServer(Ptr,servers[j]->name)) - { - me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey); - log(DEBUG,"Sent L token (no reason)"); - } + me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey); + log(DEBUG,"Sent L token (no reason)"); } } } @@ -1767,7 +1764,8 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason) for (int i =0; i != MAXCHANS; i++) { /* zap it from the channel list of the user */ - if (user->chans[i].channel == Ptr) + if (user->chans[i].channel) + if (!strcasecmp(user->chans[i].channel->name,Ptr->name)) { WriteChannel(Ptr,src,"KICK %s %s :%s",Ptr->name, user->nick, reason); user->chans[i].uc_modes = 0; @@ -3777,10 +3775,11 @@ void handle_kick(char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, parameters[0]); return; } + + char reason[MAXBUF]; if (pcnt > 2) { - char reason[MAXBUF]; strncpy(reason,parameters[2],MAXBUF); if (strlen(reason)>MAXKICK) { @@ -3791,8 +3790,23 @@ void handle_kick(char **parameters, int pcnt, userrec *user) } else { - kick_channel(user,u,Ptr,user->nick); + strcpy(reason,user->nick); + kick_channel(user,u,Ptr,reason); + } + + // this must be propogated so that channel membership is kept in step network-wide + + char buffer[MAXBUF]; + snprintf(buffer,MAXBUF,"k %s %s %s :%s",user->nick,u->nick,Ptr->name,reason); + for (int j = 0; j < 255; j++) + { + if (servers[j] != NULL) + { + me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey); + log(DEBUG,"Sent k token"); + } } + } @@ -6140,6 +6154,23 @@ void handle_n(char token,char* params,serverrec* source,serverrec* reply, char* } } +// k : +void handle_k(char token,char* params,serverrec* source,serverrec* reply, char* udp_host,int udp_port) +{ + char* src = strtok(params," "); + char* dest = strtok(NULL," "); + char* channel = strtok(NULL," :"); + char* reason = strtok(NULL,"\r\n"); + reason++; + userrec* s = Find(src); + userrec* d = Find(dest); + chanrec* c = FindChan(channel); + if ((s) && (d) && (c)) + { + kick_channel(s,d,c,reason); + } +} + void handle_N(char token,char* params,serverrec* source,serverrec* reply, char* udp_host,int udp_port) { char* tm = strtok(params," "); @@ -6265,6 +6296,10 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve case 'N': handle_N(token,params,source,reply,udp_host,udp_port); break; + // k : + case 'k': + handle_k(token,params,source,reply,udp_host,udp_port); + break; // n // change nickname of client -- a server should only be able to // change the nicknames of clients that reside on it unless -- cgit v1.2.3