]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-server.c
- SQUIT wird nicht mehr zweimal fuer einen Server verschickt.
[ngircd-alex.git] / src / ngircd / irc-server.c
index a9dde9ed15409267846fc63f61f1fa7dc2297691..b1af160f5d828f3dd03173272b4e23a1722be32d 100644 (file)
@@ -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.18 2002/10/04 11:21:46 alex Exp $
+ * $Id: irc-server.c,v 1.22 2002/11/28 14:31:43 alex Exp $
  *
  * irc-server.c: IRC-Befehle fuer Server-Links
  */
@@ -47,6 +47,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
        INT max_hops, i;
        CHANNEL *chan;
        BOOLEAN ok;
+       CONN_ID con;
        
        assert( Client != NULL );
        assert( Req != NULL );
@@ -71,10 +72,10 @@ 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;
                }
@@ -86,18 +87,19 @@ 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 */
                        ok = TRUE;
-                       if( ! IRC_WriteStrClient( Client, "PASS %s %s", Conf_Server[i].pwd, NGIRCd_ProtoID )) 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 )
                        {
-                               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,9 +112,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( 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;
@@ -339,9 +355,6 @@ IRC_SQUIT( CLIENT *Client, REQUEST *Req )
 
        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 )
        {