diff options
| author | Alexander Barton <alex@barton.de> | 2002-02-23 21:39:48 +0000 |
|---|---|---|
| committer | Alexander Barton <alex@barton.de> | 2002-02-23 21:39:48 +0000 |
| commit | aaa682fb2461f73eab0a40295cb7d331a72bcb89 (patch) | |
| tree | a241e10cf57866f362ac0111e099d9ca07bdda4a /src | |
| parent | 6f955d2a343784a8b93b4857d5547a725b5ed1c8 (diff) | |
| download | ngircd-aaa682fb2461f73eab0a40295cb7d331a72bcb89.tar.gz ngircd-aaa682fb2461f73eab0a40295cb7d331a72bcb89.zip | |
- IRC-Befehl KILL sowie Kills bei Nick Collsisions implementiert.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngircd/irc.c | 63 | ||||
| -rw-r--r-- | src/ngircd/irc.h | 6 | ||||
| -rw-r--r-- | src/ngircd/parse.c | 6 |
3 files changed, 64 insertions, 11 deletions
diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c index 5bfee00f..2ecdfaeb 100644 --- a/src/ngircd/irc.c +++ b/src/ngircd/irc.c @@ -9,11 +9,14 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: irc.c,v 1.65 2002/02/23 00:03:54 alex Exp $ + * $Id: irc.c,v 1.66 2002/02/23 21:39:48 alex Exp $ * * irc.c: IRC-Befehle * * $Log: irc.c,v $ + * Revision 1.66 2002/02/23 21:39:48 alex + * - IRC-Befehl KILL sowie Kills bei Nick Collsisions implementiert. + * * Revision 1.65 2002/02/23 00:03:54 alex * - Ergebnistyp von Conn_GetIdle() und Conn_LastPing() auf "time_t" geaendert. * @@ -279,7 +282,7 @@ LOCAL BOOLEAN Hello_User( CLIENT *Client ); LOCAL BOOLEAN Show_MOTD( CLIENT *Client ); -LOCAL VOID Kill_Nick( CHAR *Nick ); +LOCAL VOID Kill_Nick( CHAR *Nick, CHAR *Reason ); LOCAL BOOLEAN Send_NAMES( CLIENT *Client, CHANNEL *Chan ); LOCAL BOOLEAN Send_LUSERS( CLIENT *Client ); @@ -904,7 +907,7 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req ) * sowohl der neue, als auch der alte Client muessen nun * disconnectiert werden. */ Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] ); - Kill_Nick( Req->argv[0] ); + Kill_Nick( Req->argv[0], "Nick collision" ); return CONNECTED; } @@ -913,7 +916,7 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req ) if( ! intr_c ) { Log( LOG_ERR, "Server %s introduces nick \"%s\" on unknown server!?", Client_ID( Client ), Req->argv[0] ); - Kill_Nick( Req->argv[0] ); + Kill_Nick( Req->argv[0], "Unknown server" ); return CONNECTED; } @@ -925,7 +928,7 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req ) * Der Client muss disconnectiert werden, damit der Netz- * status konsistent bleibt. */ Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client )); - Kill_Nick( Req->argv[0] ); + Kill_Nick( Req->argv[0], "Server error" ); return CONNECTED; } @@ -2079,6 +2082,38 @@ GLOBAL BOOLEAN IRC_VERSION( CLIENT *Client, REQUEST *Req ) } /* IRC_VERSION */ +GLOBAL BOOLEAN IRC_KILL( CLIENT *Client, REQUEST *Req ) +{ + CLIENT *prefix, *c; + + assert( Client != NULL ); + assert( Req != NULL ); + + if( Client_Type( Client ) != CLIENT_SERVER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client )); + + /* Falsche Anzahl Parameter? */ + if(( Req->argc != 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + + prefix = Client_GetFromID( Req->prefix ); + if( ! prefix ) + { + Log( LOG_WARNING, "Got KILL with invalid prefix: \"%s\"!", Req->prefix ); + prefix = Client_ThisServer( ); + } + + Log( LOG_NOTICE, "Got KILL command from \"%s\" for \"%s\": %s", Client_Mask( prefix ), Req->argv[0], Req->argv[1] ); + + /* andere Server benachrichtigen */ + IRC_WriteStrServersPrefix( Client, prefix, "KILL %s :%s", Req->argv[0], Req->argv[1] ); + + /* haben wir selber einen solchen Client? */ + c = Client_GetFromID( Req->argv[0] ); + if( c && ( Client_Conn( c ) != NONE )) Conn_Close( Client_Conn( c ), NULL, Req->argv[1], TRUE ); + + return CONNECTED; +} /* IRC_KILL */ + + LOCAL BOOLEAN Hello_User( CLIENT *Client ) { assert( Client != NULL ); @@ -2145,11 +2180,21 @@ LOCAL BOOLEAN Show_MOTD( CLIENT *Client ) } /* Show_MOTD */ -LOCAL VOID Kill_Nick( CHAR *Nick ) +LOCAL VOID Kill_Nick( CHAR *Nick, CHAR *Reason ) { - Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected!", Nick ); - /* FIXME */ - Log( LOG_ALERT, "[Kill_Nick() not implemented - OOOPS!]" ); + CLIENT *c; + + assert( Nick != NULL ); + assert( Reason != NULL ); + + Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason ); + + /* andere Server benachrichtigen */ + IRC_WriteStrServers( NULL, "KILL %s :%s", Nick, Reason ); + + /* Ggf. einen eigenen Client toeten */ + c = Client_GetFromID( Nick ); + if( c && ( Client_Conn( c ) != NONE )) Conn_Close( Client_Conn( c ), NULL, Reason, TRUE ); } /* Kill_Nick */ diff --git a/src/ngircd/irc.h b/src/ngircd/irc.h index 285b8a52..e796038f 100644 --- a/src/ngircd/irc.h +++ b/src/ngircd/irc.h @@ -9,11 +9,14 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: irc.h,v 1.23 2002/02/17 23:38:58 alex Exp $ + * $Id: irc.h,v 1.24 2002/02/23 21:39:48 alex Exp $ * * irc.h: IRC-Befehle (Header) * * $Log: irc.h,v $ + * Revision 1.24 2002/02/23 21:39:48 alex + * - IRC-Befehl KILL sowie Kills bei Nick Collsisions implementiert. + * * Revision 1.23 2002/02/17 23:38:58 alex * - neuer IRC-Befehl VERSION implementiert: IRC_VERSION(). * @@ -142,6 +145,7 @@ GLOBAL BOOLEAN IRC_DIE( CLIENT *Client, REQUEST *Req ); GLOBAL BOOLEAN IRC_RESTART( CLIENT *Client, REQUEST *Req ); GLOBAL BOOLEAN IRC_ERROR( CLIENT *Client, REQUEST *Req ); +GLOBAL BOOLEAN IRC_KILL( CLIENT *Client, REQUEST *Req ); GLOBAL BOOLEAN IRC_JOIN( CLIENT *Client, REQUEST *Req ); GLOBAL BOOLEAN IRC_PART( CLIENT *Client, REQUEST *Req ); diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c index 79c5d16f..361158e9 100644 --- a/src/ngircd/parse.c +++ b/src/ngircd/parse.c @@ -9,11 +9,14 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: parse.c,v 1.23 2002/02/17 23:38:58 alex Exp $ + * $Id: parse.c,v 1.24 2002/02/23 21:39:48 alex Exp $ * * parse.c: Parsen der Client-Anfragen * * $Log: parse.c,v $ + * Revision 1.24 2002/02/23 21:39:48 alex + * - IRC-Befehl KILL sowie Kills bei Nick Collsisions implementiert. + * * Revision 1.23 2002/02/17 23:38:58 alex * - neuer IRC-Befehl VERSION implementiert: IRC_VERSION(). * @@ -371,6 +374,7 @@ LOCAL BOOLEAN Handle_Request( CONN_ID Idx, REQUEST *Req ) else if( strcasecmp( Req->command, "JOIN" ) == 0 ) return IRC_JOIN( client, Req ); else if( strcasecmp( Req->command, "PART" ) == 0 ) return IRC_PART( client, Req ); else if( strcasecmp( Req->command, "VERSION" ) == 0 ) return IRC_VERSION( client, Req ); + else if( strcasecmp( Req->command, "KILL" ) == 0 ) return IRC_KILL( client, Req ); /* Unbekannter Befehl */ if( Client_Type( client ) != CLIENT_SERVER ) IRC_WriteStrClient( client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( client ), Req->command ); |