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=ec867ed84f28f06a7d3ce42adaf55cef4f54c2fa;hp=6ea1d2681e1f05f0c32c380523e48ab256df2e27;hb=4eb57b590bcf64c51583a58a4ebbef83dd79ea84;hpb=bc4ed22635b00f4906ec1f8dcce44bc86bf00444 diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c index 6ea1d268..ec867ed8 100644 --- a/src/ngircd/irc-server.c +++ b/src/ngircd/irc-server.c @@ -9,7 +9,7 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: irc-server.c,v 1.7 2002/03/25 17:12:22 alex Exp $ + * $Id: irc-server.c,v 1.20 2002/11/19 12:50:20 alex Exp $ * * irc-server.c: IRC-Befehle fuer Server-Links */ @@ -23,16 +23,23 @@ #include #include +#include "resolve.h" #include "conf.h" +#include "conn.h" +#include "client.h" +#include "channel.h" #include "irc-write.h" #include "log.h" #include "messages.h" +#include "parse.h" +#include "ngircd.h" #include "exp.h" #include "irc-server.h" -GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req ) +GLOBAL BOOLEAN +IRC_SERVER( CLIENT *Client, REQUEST *Req ) { CHAR str[LINE_LEN], *ptr; CLIENT *from, *c, *cl; @@ -64,10 +71,10 @@ GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req ) Conn_Close( Client_Conn( Client ), NULL, "Server not configured here", TRUE ); return DISCONNECTED; } - if( strcmp( Client_Password( Client ), Conf_Server[i].pwd ) != 0 ) + if( strcmp( Client_Password( Client ), Conf_Server[i].pwd_in ) != 0 ) { /* Falsches Passwort */ - Log( LOG_ERR, "Connection %d: Bad password for server \"%s\"!", Client_Conn( Client ), Req->argv[0] ); + Log( LOG_ERR, "Connection %d: Got bad password from server \"%s\"!", Client_Conn( Client ), Req->argv[0] ); Conn_Close( Client_Conn( Client ), NULL, "Bad password", TRUE ); return DISCONNECTED; } @@ -80,12 +87,13 @@ GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req ) Client_SetHops( Client, 1 ); Client_SetInfo( Client, Req->argv[Req->argc - 1] ); - /* Meldet sich der Server bei uns an? */ - if( Req->argc == 2 ) + /* Meldet sich der Server bei uns an (d.h., bauen nicht wir + * selber die Verbindung zu einem anderen Server auf)? */ + if( Client_Token( Client ) != TOKEN_OUTBOUND ) { - /* Unseren SERVER- und PASS-Befehl senden */ + /* Eingehende Verbindung: Unseren SERVER- und PASS-Befehl senden */ ok = TRUE; - if( ! IRC_WriteStrClient( Client, "PASS %s "PASSSERVERADD, Conf_Server[i].pwd )) ok = FALSE; + if( ! IRC_WriteStrClient( Client, "PASS %s %s", Conf_Server[i].pwd_out, NGIRCd_ProtoID )) ok = FALSE; else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo ); if( ! ok ) { @@ -95,11 +103,17 @@ GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req ) Client_SetIntroducer( Client, Client ); Client_SetToken( Client, 1 ); } - else Client_SetToken( Client, atoi( Req->argv[1] )); + else + { + /* Ausgehende verbindung, SERVER und PASS wurden von uns bereits + * an die Gegenseite uerbermittelt */ + Client_SetToken( Client, atoi( Req->argv[1] )); + } - Log( LOG_NOTICE, "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 ), Client_Conn( Client )); Client_SetType( Client, CLIENT_SERVER ); + Conn_SetServer( Client_Conn( Client ), i ); /* maximalen Hop Count ermitteln */ max_hops = 0; @@ -149,6 +163,15 @@ GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req ) chan = Channel_First( ); while( chan ) { +#ifdef IRCPLUS + /* Wenn unterstuetzt, CHANINFO senden */ + if( strchr( Client_Flags( Client ), 'C' )) + { + /* CHANINFO senden */ + if( ! IRC_WriteStrClient( Client, "CHANINFO %s +%s :%s", Channel_Name( chan ), Channel_Modes( chan ), Channel_Topic( chan ))) return DISCONNECTED; + } +#endif + /* alle Member suchen */ cl2chan = Channel_FirstMember( chan ); sprintf( str, "NJOIN %s :", Channel_Name( chan )); @@ -166,7 +189,7 @@ GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req ) if( strlen( str ) > ( LINE_LEN - CLIENT_NICK_LEN - 8 )) { /* Zeile senden */ - if( ! IRC_WriteStrClient( Client, str )) return DISCONNECTED; + if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED; sprintf( str, "NJOIN %s :", Channel_Name( chan )); } @@ -177,7 +200,7 @@ GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req ) if( str[strlen( str ) - 1] != ':') { /* Ja; Also senden ... */ - if( ! IRC_WriteStrClient( Client, str )) return DISCONNECTED; + if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED; } /* naechsten Channel suchen */ @@ -222,7 +245,7 @@ GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req ) /* Log-Meldung zusammenbauen und ausgeben */ if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) sprintf( str, "connected to %s, ", Client_ID( from )); else strcpy( str, "" ); - Log( LOG_NOTICE, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" ); + Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" ); /* Andere Server informieren */ IRC_WriteStrServersPrefix( Client, from, "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c )); @@ -233,9 +256,10 @@ GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req ) } /* IRC_SERVER */ -GLOBAL BOOLEAN IRC_NJOIN( CLIENT *Client, REQUEST *Req ) +GLOBAL BOOLEAN +IRC_NJOIN( CLIENT *Client, REQUEST *Req ) { - CHAR *channame, *ptr, modes[8]; + CHAR str[COMMAND_LEN], *channame, *ptr, modes[8]; BOOLEAN is_op, is_voiced; CHANNEL *chan; CLIENT *c; @@ -248,8 +272,11 @@ GLOBAL BOOLEAN IRC_NJOIN( CLIENT *Client, REQUEST *Req ) /* 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'; + channame = Req->argv[0]; - ptr = strtok( Req->argv[1], "," ); + ptr = strtok( str, "," ); while( ptr ) { is_op = is_voiced = FALSE; @@ -296,7 +323,8 @@ GLOBAL BOOLEAN IRC_NJOIN( CLIENT *Client, REQUEST *Req ) } /* IRC_NJOIN */ -GLOBAL BOOLEAN IRC_SQUIT( CLIENT *Client, REQUEST *Req ) +GLOBAL BOOLEAN +IRC_SQUIT( CLIENT *Client, REQUEST *Req ) { CLIENT *target; CHAR msg[LINE_LEN + 64];