X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fparse.c;h=ad04717c664bdd81ced6b10ab97be635c81bc721;hb=9e18ec30ff1e607a209625012d2a1e00c96d81ca;hp=ef8459645acb10a63f9d6bc37f4997cdd8f413e1;hpb=356683ff6ea1c770f481483ddf7013cd03a1ef2e;p=ngircd-alex.git diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c index ef845964..ad04717c 100644 --- a/src/ngircd/parse.c +++ b/src/ngircd/parse.c @@ -9,11 +9,26 @@ * 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.13 2002/01/04 01:20:02 alex Exp $ + * $Id: parse.c,v 1.18 2002/01/07 15:29:11 alex Exp $ * * parse.c: Parsen der Client-Anfragen * * $Log: parse.c,v $ + * Revision 1.18 2002/01/07 15:29:11 alex + * - Status-Codes an den Server selber werden ignoriert, besseres Logging. + * + * Revision 1.17 2002/01/06 17:41:44 alex + * - die Fehlermeldung "unbekannter Befehl" hatte ein falsches Format. + * + * Revision 1.16 2002/01/05 23:23:20 alex + * - generisches Forwarding von Zahlen-Statuscodes implementiert. + * + * Revision 1.15 2002/01/05 01:42:08 alex + * - an Server werden keine ERRORS mehr wegen unbekannter Befehle geschickt. + * + * Revision 1.14 2002/01/04 17:56:45 alex + * - neuer Befehl SQUIT. + * * Revision 1.13 2002/01/04 01:20:02 alex * - Client-Strukruren werden nur noch ueber Funktionen angesprochen. * @@ -69,6 +84,7 @@ #include #include +#include #include #include @@ -237,7 +253,9 @@ LOCAL BOOLEAN Handle_Request( CONN_ID Idx, REQUEST *Req ) /* Client-Request verarbeiten. Bei einem schwerwiegenden Fehler * wird die Verbindung geschlossen und FALSE geliefert. */ - CLIENT *client; + CLIENT *client, *target, *prefix; + CHAR str[LINE_LEN]; + INT i; assert( Idx >= 0 ); assert( Req != NULL ); @@ -246,12 +264,57 @@ LOCAL BOOLEAN Handle_Request( CONN_ID Idx, REQUEST *Req ) client = Client_GetFromConn( Idx ); assert( client != NULL ); + /* Statuscode, der geforwarded werden muss? */ + if(( strlen( Req->command ) == 3 ) && ( atoi( Req->command ) > 100 )) + { + /* Befehl ist ein Statuscode */ + + /* Zielserver ermitteln */ + if(( Client_Type( client ) == CLIENT_SERVER ) && ( Req->argc > 0 )) target = Client_GetFromID( Req->argv[0] ); + else target = NULL; + if( ! target ) + { + if( target ) Log( LOG_WARNING, "Unknown target for status code: \"%s\"", Req->argv[0] ); + else Log( LOG_WARNING, "Unknown target for status code!" ); + return TRUE; + } + if( target == Client_ThisServer( )) + { + Log( LOG_DEBUG, "Ignored status code %s from \"%s\".", Req->command, Client_ID( client )); + return TRUE; + } + + /* Quell-Client ermitteln */ + if( ! Req->prefix[0] ) + { + Log( LOG_WARNING, "Got status code without prefix!?" ); + return TRUE; + } + else prefix = Client_GetFromID( Req->prefix ); + if( ! prefix ) + { + Log( LOG_WARNING, "Got status code from unknown source: \"%s\"", Req->prefix ); + return TRUE; + } + + /* Statuscode weiterleiten */ + strcpy( str, Req->command ); + for( i = 0; i < Req->argc; i++ ) + { + if( i < Req->argc - 1 ) strcat( str, " " ); + else strcat( str, " :" ); + strcat( str, Req->argv[i] ); + } + return IRC_WriteStrClientPrefix( target, prefix, str ); + } + if( strcasecmp( Req->command, "PASS" ) == 0 ) return IRC_PASS( client, Req ); else if( strcasecmp( Req->command, "NICK" ) == 0 ) return IRC_NICK( client, Req ); else if( strcasecmp( Req->command, "USER" ) == 0 ) return IRC_USER( client, Req ); else if( strcasecmp( Req->command, "SERVER" ) == 0 ) return IRC_SERVER( client, Req ); else if( strcasecmp( Req->command, "NJOIN" ) == 0 ) return IRC_NJOIN( client, Req ); else if( strcasecmp( Req->command, "QUIT" ) == 0 ) return IRC_QUIT( client, Req ); + else if( strcasecmp( Req->command, "SQUIT" ) == 0 ) return IRC_SQUIT( client, Req ); else if( strcasecmp( Req->command, "PING" ) == 0 ) return IRC_PING( client, Req ); else if( strcasecmp( Req->command, "PONG" ) == 0 ) return IRC_PONG( client, Req ); else if( strcasecmp( Req->command, "MOTD" ) == 0 ) return IRC_MOTD( client, Req ); @@ -268,8 +331,8 @@ LOCAL BOOLEAN Handle_Request( CONN_ID Idx, REQUEST *Req ) else if( strcasecmp( Req->command, "ERROR" ) == 0 ) return IRC_ERROR( client, Req ); /* Unbekannter Befehl */ - IRC_WriteStrClient( client, Client_ThisServer( ), ERR_UNKNOWNCOMMAND_MSG, Client_ID( client ), Req->command ); - Log( LOG_DEBUG, "User \"%s\": Unknown command \"%s\", %d %s,%s prefix.", Client_Mask( client ), Req->command, Req->argc, Req->argc == 1 ? "parameter" : "parameters", Req->prefix ? "" : " no" ); + if( Client_Type( client ) != CLIENT_SERVER ) IRC_WriteStrClient( client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( client ), Req->command ); + Log( LOG_DEBUG, "Connection %d: Unknown command \"%s\", %d %s,%s prefix.", Client_Conn( client ), Req->command, Req->argc, Req->argc == 1 ? "parameter" : "parameters", Req->prefix ? "" : " no" ); return TRUE; } /* Handle_Request */