X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Firc-server.c;h=6a6f4712febfcfc632a22f27aa111dcf7c289cae;hp=ec867ed84f28f06a7d3ce42adaf55cef4f54c2fa;hb=6626395c88fc46eeb110942b17eb9245a1d0021b;hpb=b2615bcc765a791d9fb836848fd953641bba48ec diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c index ec867ed8..6a6f4712 100644 --- a/src/ngircd/irc-server.c +++ b/src/ngircd/irc-server.c @@ -2,21 +2,20 @@ * ngIRCd -- The Next Generation IRC Daemon * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de) * - * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen - * der GNU General Public License (GPL), wie von der Free Software Foundation - * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2 - * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version. - * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste - * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: irc-server.c,v 1.20 2002/11/19 12:50:20 alex Exp $ - * - * irc-server.c: IRC-Befehle fuer Server-Links + * IRC commands for server links */ #include "portab.h" +static char UNUSED id[] = "$Id: irc-server.c,v 1.26 2002/12/26 16:48:14 alex Exp $"; + #include "imp.h" #include #include @@ -47,6 +46,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) INT max_hops, i; CHANNEL *chan; BOOLEAN ok; + CONN_ID con; assert( Client != NULL ); assert( Req != NULL ); @@ -86,9 +86,10 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) Client_SetID( Client, Req->argv[0] ); Client_SetHops( Client, 1 ); Client_SetInfo( Client, Req->argv[Req->argc - 1] ); - + /* Meldet sich der Server bei uns an (d.h., bauen nicht wir * selber die Verbindung zu einem anderen Server auf)? */ + con = Client_Conn( Client ); if( Client_Token( Client ) != TOKEN_OUTBOUND ) { /* Eingehende Verbindung: Unseren SERVER- und PASS-Befehl senden */ @@ -97,7 +98,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo ); if( ! ok ) { - Conn_Close( Client_Conn( Client ), "Unexpected server behavior!", NULL, FALSE ); + Conn_Close( con, "Unexpected server behavior!", NULL, FALSE ); return DISCONNECTED; } Client_SetIntroducer( Client, Client ); @@ -110,10 +111,23 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) Client_SetToken( Client, atoi( Req->argv[1] )); } - Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (connection %d, 1 hop - direct link).", Client_ID( Client ), Client_Conn( Client )); + Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (connection %d, 1 hop - direct link).", Client_ID( Client ), con ); Client_SetType( Client, CLIENT_SERVER ); - Conn_SetServer( Client_Conn( Client ), i ); + Conn_SetServer( con, i ); + +#ifdef USE_ZLIB + /* Kompression initialisieren, wenn erforderlich */ + if( strchr( Client_Flags( Client ), 'Z' )) + { + if( ! Conn_InitZip( con )) + { + /* Fehler! */ + Conn_Close( con, "Can't inizialize compression (zlib)!", NULL, FALSE ); + return DISCONNECTED; + } + } +#endif /* maximalen Hop Count ermitteln */ max_hops = 0; @@ -181,10 +195,10 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) assert( cl != NULL ); /* Nick, ggf. mit Modes, anhaengen */ - if( str[strlen( str ) - 1] != ':' ) strcat( str, "," ); - if( strchr( Channel_UserModes( chan, cl ), 'v' )) strcat( str, "+" ); - if( strchr( Channel_UserModes( chan, cl ), 'o' )) strcat( str, "@" ); - strcat( str, Client_ID( cl )); + if( str[strlen( str ) - 1] != ':' ) strlcat( str, ",", sizeof( str )); + if( strchr( Channel_UserModes( chan, cl ), 'v' )) strlcat( str, "+", sizeof( str )); + if( strchr( Channel_UserModes( chan, cl ), 'o' )) strlcat( str, "@", sizeof( str )); + strlcat( str, Client_ID( cl ), sizeof( str )); if( strlen( str ) > ( LINE_LEN - CLIENT_NICK_LEN - 8 )) { @@ -267,13 +281,10 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - if( Client_Type( Client ) != CLIENT_SERVER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTEREDSERVER_MSG, Client_ID( Client )); - /* Falsche Anzahl Parameter? */ if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); - strncpy( str, Req->argv[1], COMMAND_LEN - 1 ); - str[COMMAND_LEN - 1] = '\0'; + strlcpy( str, Req->argv[1], sizeof( str )); channame = Req->argv[0]; ptr = strtok( str, "," ); @@ -332,17 +343,11 @@ IRC_SQUIT( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - /* SQUIT ist nur fuer Server erlaubt */ - 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 ); Log( LOG_DEBUG, "Got SQUIT from %s for \"%s\": \"%s\" ...", Client_ID( Client ), Req->argv[0], Req->argv[1] ); - /* SQUIT an alle Server weiterleiten */ - IRC_WriteStrServers( Client, "SQUIT %s :%s", Req->argv[0], Req->argv[1] ); - target = Client_Search( Req->argv[0] ); if( ! target ) {