- Unterstuetzung fuer komprimierte Server-Server-Links implementiert.
This commit is contained in:
parent
ecde730ec4
commit
65f3adca21
|
@ -9,7 +9,7 @@
|
||||||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||||
*
|
*
|
||||||
* $Id: conn.c,v 1.95 2002/11/23 17:04:07 alex Exp $
|
* $Id: conn.c,v 1.96 2002/11/26 23:07:24 alex Exp $
|
||||||
*
|
*
|
||||||
* connect.h: Verwaltung aller Netz-Verbindungen ("connections")
|
* connect.h: Verwaltung aller Netz-Verbindungen ("connections")
|
||||||
*/
|
*/
|
||||||
|
@ -42,6 +42,10 @@
|
||||||
#include <stdint.h> /* u.a. fuer Mac OS X */
|
#include <stdint.h> /* u.a. fuer Mac OS X */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
#include <zlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "exp.h"
|
#include "exp.h"
|
||||||
#include "conn.h"
|
#include "conn.h"
|
||||||
|
|
||||||
|
@ -60,6 +64,20 @@
|
||||||
#define SERVER_WAIT (NONE - 1)
|
#define SERVER_WAIT (NONE - 1)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
typedef struct _ZipData
|
||||||
|
{
|
||||||
|
z_stream in; /* "Handle" fuer Input-Stream */
|
||||||
|
z_stream out; /* "Handle" fuer Output-Stream */
|
||||||
|
CHAR rbuf[READBUFFER_LEN]; /* Lesepuffer */
|
||||||
|
INT rdatalen; /* Laenge der Daten im Lesepuffer (komprimiert) */
|
||||||
|
CHAR wbuf[WRITEBUFFER_LEN]; /* Schreibpuffer */
|
||||||
|
INT wdatalen; /* Laenge der Daten im Schreibpuffer (unkomprimiert) */
|
||||||
|
LONG bytes_in, bytes_out; /* Counter fuer Statistik (unkomprimiert!) */
|
||||||
|
} ZIPDATA;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef struct _Connection
|
typedef struct _Connection
|
||||||
{
|
{
|
||||||
INT sock; /* Socket Handle */
|
INT sock; /* Socket Handle */
|
||||||
|
@ -76,7 +94,11 @@ typedef struct _Connection
|
||||||
time_t lastprivmsg; /* Letzte PRIVMSG */
|
time_t lastprivmsg; /* Letzte PRIVMSG */
|
||||||
time_t delaytime; /* Nicht beachten bis ("penalty") */
|
time_t delaytime; /* Nicht beachten bis ("penalty") */
|
||||||
LONG bytes_in, bytes_out; /* Counter fuer Statistik */
|
LONG bytes_in, bytes_out; /* Counter fuer Statistik */
|
||||||
INT flag; /* Channel-Flag (vgl. "irc-write"-Modul) */
|
INT flag; /* "Markierungs-Flag" (vgl. "irc-write"-Modul) */
|
||||||
|
INT options; /* Link-Optionen */
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
ZIPDATA zip; /* Kompressionsinformationen */
|
||||||
|
#endif
|
||||||
} CONNECTION;
|
} CONNECTION;
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,6 +116,12 @@ LOCAL BOOLEAN Init_Socket PARAMS(( INT Sock ));
|
||||||
LOCAL VOID New_Server PARAMS(( INT Server, CONN_ID Idx ));
|
LOCAL VOID New_Server PARAMS(( INT Server, CONN_ID Idx ));
|
||||||
LOCAL VOID Read_Resolver_Result PARAMS(( INT r_fd ));
|
LOCAL VOID Read_Resolver_Result PARAMS(( INT r_fd ));
|
||||||
|
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
LOCAL BOOLEAN Zip_Buffer PARAMS(( CONN_ID Idx, CHAR *Data, INT Len ));
|
||||||
|
LOCAL BOOLEAN Zip_Flush PARAMS(( CONN_ID Idx ));
|
||||||
|
LOCAL BOOLEAN Unzip_Buffer PARAMS(( CONN_ID Idx ));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
LOCAL fd_set My_Listeners;
|
LOCAL fd_set My_Listeners;
|
||||||
LOCAL fd_set My_Sockets;
|
LOCAL fd_set My_Sockets;
|
||||||
|
@ -322,7 +350,11 @@ Conn_Handler( VOID )
|
||||||
FD_ZERO( &write_sockets );
|
FD_ZERO( &write_sockets );
|
||||||
for( i = 0; i < Pool_Size; i++ )
|
for( i = 0; i < Pool_Size; i++ )
|
||||||
{
|
{
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
if(( My_Connections[i].sock > NONE ) && (( My_Connections[i].wdatalen > 0 ) || ( My_Connections[i].zip.wdatalen > 0 )))
|
||||||
|
#else
|
||||||
if(( My_Connections[i].sock > NONE ) && ( My_Connections[i].wdatalen > 0 ))
|
if(( My_Connections[i].sock > NONE ) && ( My_Connections[i].wdatalen > 0 ))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/* Socket der Verbindung in Set aufnehmen */
|
/* Socket der Verbindung in Set aufnehmen */
|
||||||
FD_SET( My_Connections[i].sock, &write_sockets );
|
FD_SET( My_Connections[i].sock, &write_sockets );
|
||||||
|
@ -471,41 +503,47 @@ Conn_Write( CONN_ID Idx, CHAR *Data, INT Len )
|
||||||
assert( Data != NULL );
|
assert( Data != NULL );
|
||||||
assert( Len > 0 );
|
assert( Len > 0 );
|
||||||
|
|
||||||
/* Ist der entsprechende Socket ueberhaupt noch offen?
|
/* Ist der entsprechende Socket ueberhaupt noch offen? In einem
|
||||||
* In einem "Handler-Durchlauf" kann es passieren, dass
|
* "Handler-Durchlauf" kann es passieren, dass dem nicht mehr so
|
||||||
* dem nicht mehr so ist, wenn einer von mehreren
|
* ist, wenn einer von mehreren Conn_Write()'s fehlgeschlagen ist.
|
||||||
* Conn_Write()'s fehlgeschlagen ist. In diesem Fall
|
* In diesem Fall wird hier einfach ein Fehler geliefert. */
|
||||||
* wird hier einfach ein Fehler geliefert. */
|
|
||||||
if( My_Connections[Idx].sock <= NONE )
|
if( My_Connections[Idx].sock <= NONE )
|
||||||
{
|
{
|
||||||
Log( LOG_DEBUG, "Skipped write on closed socket (connection %d).", Idx );
|
Log( LOG_DEBUG, "Skipped write on closed socket (connection %d).", Idx );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pruefen, ob Daten im Schreibpuffer sind. Wenn ja, zunaechst
|
/* Pruefen, ob im Schreibpuffer genuegend Platz ist. Ziel ist es,
|
||||||
* pruefen, ob diese gesendet werden koennen */
|
* moeglichts viel im Puffer zu haben und _nicht_ gleich alles auf den
|
||||||
if( My_Connections[Idx].wdatalen > 0 )
|
* Socket zu schreiben (u.a. wg. Komprimierung). */
|
||||||
{
|
|
||||||
if( ! Try_Write( Idx )) return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* pruefen, ob im Schreibpuffer genuegend Platz ist */
|
|
||||||
if( WRITEBUFFER_LEN - My_Connections[Idx].wdatalen - Len <= 0 )
|
if( WRITEBUFFER_LEN - My_Connections[Idx].wdatalen - Len <= 0 )
|
||||||
{
|
{
|
||||||
/* der Puffer ist dummerweise voll ... */
|
/* Der Puffer ist dummerweise voll. Jetzt versuchen, den Puffer
|
||||||
Log( LOG_NOTICE, "Write buffer overflow (connection %d)!", Idx );
|
* zu schreiben, wenn das nicht klappt, haben wir ein Problem ... */
|
||||||
Conn_Close( Idx, "Write buffer overflow!", NULL, FALSE );
|
if( ! Try_Write( Idx )) return FALSE;
|
||||||
return FALSE;
|
|
||||||
|
/* nun neu pruefen: */
|
||||||
|
if( WRITEBUFFER_LEN - My_Connections[Idx].wdatalen - Len <= 0 )
|
||||||
|
{
|
||||||
|
Log( LOG_NOTICE, "Write buffer overflow (connection %d)!", Idx );
|
||||||
|
Conn_Close( Idx, "Write buffer overflow!", NULL, FALSE );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Daten in Puffer kopieren */
|
#ifdef USE_ZLIB
|
||||||
memcpy( My_Connections[Idx].wbuf + My_Connections[Idx].wdatalen, Data, Len );
|
if( My_Connections[Idx].options & CONN_ZIP )
|
||||||
My_Connections[Idx].wdatalen += Len;
|
|
||||||
|
|
||||||
/* pruefen, on Daten vorhanden sind und geschrieben werden koennen */
|
|
||||||
if( My_Connections[Idx].wdatalen > 0 )
|
|
||||||
{
|
{
|
||||||
if( ! Try_Write( Idx )) return FALSE;
|
/* Daten komprimieren und in Puffer kopieren */
|
||||||
|
if( ! Zip_Buffer( Idx, Data, Len )) return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* Daten in Puffer kopieren */
|
||||||
|
memcpy( My_Connections[Idx].wbuf + My_Connections[Idx].wdatalen, Data, Len );
|
||||||
|
My_Connections[Idx].wdatalen += Len;
|
||||||
|
My_Connections[Idx].bytes_out += Len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -519,6 +557,11 @@ Conn_Close( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient )
|
||||||
* Sub-Prozessen offene Pipes werden geschlossen. */
|
* Sub-Prozessen offene Pipes werden geschlossen. */
|
||||||
|
|
||||||
CLIENT *c;
|
CLIENT *c;
|
||||||
|
DOUBLE in_k, out_k;
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
DOUBLE in_z_k, out_z_k;
|
||||||
|
INT in_p, out_p;
|
||||||
|
#endif
|
||||||
|
|
||||||
assert( Idx > NONE );
|
assert( Idx > NONE );
|
||||||
assert( My_Connections[Idx].sock > NONE );
|
assert( My_Connections[Idx].sock > NONE );
|
||||||
|
@ -545,7 +588,22 @@ Conn_Close( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log( LOG_INFO, "Connection %d (socket %d) with %s:%d closed (%.1fK in/%.1fK out).", Idx, My_Connections[Idx].sock, My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port ), (DOUBLE)My_Connections[Idx].bytes_in / 1024, (DOUBLE)My_Connections[Idx].bytes_out / 1024 );
|
in_k = (DOUBLE)My_Connections[Idx].bytes_in / 1024;
|
||||||
|
out_k = (DOUBLE)My_Connections[Idx].bytes_out / 1024;
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
if( My_Connections[Idx].options & CONN_ZIP )
|
||||||
|
{
|
||||||
|
in_z_k = (DOUBLE)My_Connections[Idx].zip.bytes_in / 1024;
|
||||||
|
out_z_k = (DOUBLE)My_Connections[Idx].zip.bytes_out / 1024;
|
||||||
|
in_p = (INT)(( in_k * 100 ) / in_z_k );
|
||||||
|
out_p = (INT)(( out_k * 100 ) / out_z_k );
|
||||||
|
Log( LOG_INFO, "Connection %d (socket %d) with %s:%d closed (in: %.1fk/%.1fk/%d%%, out: %.1fk/%.1fk/%d%%).", Idx, My_Connections[Idx].sock, My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port ), in_k, in_z_k, in_p, out_k, out_z_k, out_p );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Log( LOG_INFO, "Connection %d (socket %d) with %s:%d closed (in: %.1fk, out: %.1fk).", Idx, My_Connections[Idx].sock, My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port ), in_k, out_k );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Socket als "ungueltig" markieren */
|
/* Socket als "ungueltig" markieren */
|
||||||
|
@ -574,6 +632,15 @@ Conn_Close( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient )
|
||||||
Conf_Server[My_Connections[Idx].our_server].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
|
Conf_Server[My_Connections[Idx].our_server].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
/* Ggf. zlib abmelden */
|
||||||
|
if( Conn_Options( Idx ) & CONN_ZIP )
|
||||||
|
{
|
||||||
|
inflateEnd( &My_Connections[Idx].zip.in );
|
||||||
|
deflateEnd( &My_Connections[Idx].zip.out );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Connection-Struktur loeschen (=freigeben) */
|
/* Connection-Struktur loeschen (=freigeben) */
|
||||||
Init_Conn_Struct( Idx );
|
Init_Conn_Struct( Idx );
|
||||||
} /* Conn_Close */
|
} /* Conn_Close */
|
||||||
|
@ -713,6 +780,87 @@ Conn_SetServer( CONN_ID Idx, INT ConfServer )
|
||||||
} /* Conn_SetServer */
|
} /* Conn_SetServer */
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL VOID
|
||||||
|
Conn_SetOption( CONN_ID Idx, INT Option )
|
||||||
|
{
|
||||||
|
/* Option fuer Verbindung setzen.
|
||||||
|
* Initial sind alle Optionen _nicht_ gesetzt. */
|
||||||
|
|
||||||
|
assert( Idx > NONE );
|
||||||
|
assert( Option != 0 );
|
||||||
|
|
||||||
|
My_Connections[Idx].options |= Option;
|
||||||
|
} /* Conn_SetOption */
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL VOID
|
||||||
|
Conn_UnsetOption( CONN_ID Idx, INT Option )
|
||||||
|
{
|
||||||
|
/* Option fuer Verbindung loeschen */
|
||||||
|
|
||||||
|
assert( Idx > NONE );
|
||||||
|
assert( Option != 0 );
|
||||||
|
|
||||||
|
My_Connections[Idx].options &= ~Option;
|
||||||
|
} /* Conn_UnsetOption */
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL INT
|
||||||
|
Conn_Options( CONN_ID Idx )
|
||||||
|
{
|
||||||
|
assert( Idx > NONE );
|
||||||
|
return My_Connections[Idx].options;
|
||||||
|
} /* Conn_Options */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
|
||||||
|
GLOBAL BOOLEAN
|
||||||
|
Conn_InitZip( CONN_ID Idx )
|
||||||
|
{
|
||||||
|
/* Kompression fuer Link initialisieren */
|
||||||
|
|
||||||
|
assert( Idx > NONE );
|
||||||
|
|
||||||
|
My_Connections[Idx].zip.in.avail_in = 0;
|
||||||
|
My_Connections[Idx].zip.in.total_in = 0;
|
||||||
|
My_Connections[Idx].zip.in.total_out = 0;
|
||||||
|
My_Connections[Idx].zip.in.zalloc = NULL;
|
||||||
|
My_Connections[Idx].zip.in.zfree = NULL;
|
||||||
|
My_Connections[Idx].zip.in.data_type = Z_ASCII;
|
||||||
|
|
||||||
|
if( inflateInit( &My_Connections[Idx].zip.in ) != Z_OK )
|
||||||
|
{
|
||||||
|
/* Fehler! */
|
||||||
|
Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib inflate)!", Idx );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
My_Connections[Idx].zip.out.total_in = 0;
|
||||||
|
My_Connections[Idx].zip.out.total_in = 0;
|
||||||
|
My_Connections[Idx].zip.out.zalloc = NULL;
|
||||||
|
My_Connections[Idx].zip.out.zfree = NULL;
|
||||||
|
My_Connections[Idx].zip.out.data_type = Z_ASCII;
|
||||||
|
|
||||||
|
if( deflateInit( &My_Connections[Idx].zip.out, Z_DEFAULT_COMPRESSION ) != Z_OK )
|
||||||
|
{
|
||||||
|
/* Fehler! */
|
||||||
|
Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib deflate)!", Idx );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
My_Connections[Idx].zip.bytes_in = My_Connections[Idx].bytes_in;
|
||||||
|
My_Connections[Idx].zip.bytes_out = My_Connections[Idx].bytes_out;
|
||||||
|
|
||||||
|
Log( LOG_INFO, "Enabled link compression (zlib) on connection %d.", Idx );
|
||||||
|
Conn_SetOption( Idx, CONN_ZIP );
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} /* Conn_InitZip */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
LOCAL BOOLEAN
|
LOCAL BOOLEAN
|
||||||
Try_Write( CONN_ID Idx )
|
Try_Write( CONN_ID Idx )
|
||||||
{
|
{
|
||||||
|
@ -828,6 +976,12 @@ Handle_Write( CONN_ID Idx )
|
||||||
return Conn_WriteStr( Idx, "SERVER %s :%s", Conf_ServerName, Conf_ServerInfo );
|
return Conn_WriteStr( Idx, "SERVER %s :%s", Conf_ServerName, Conf_ServerInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
/* Schreibpuffer leer, aber noch Daten im Kompressionsbuffer?
|
||||||
|
* Dann muss dieser nun geflushed werden! */
|
||||||
|
if( My_Connections[Idx].wdatalen == 0 ) Zip_Flush( Idx );
|
||||||
|
#endif
|
||||||
|
|
||||||
assert( My_Connections[Idx].wdatalen > 0 );
|
assert( My_Connections[Idx].wdatalen > 0 );
|
||||||
|
|
||||||
/* Daten schreiben */
|
/* Daten schreiben */
|
||||||
|
@ -843,9 +997,6 @@ Handle_Write( CONN_ID Idx )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connection-Statistik aktualisieren */
|
|
||||||
My_Connections[Idx].bytes_out += len;
|
|
||||||
|
|
||||||
/* Puffer anpassen */
|
/* Puffer anpassen */
|
||||||
My_Connections[Idx].wdatalen -= len;
|
My_Connections[Idx].wdatalen -= len;
|
||||||
memmove( My_Connections[Idx].wbuf, My_Connections[Idx].wbuf + len, My_Connections[Idx].wdatalen );
|
memmove( My_Connections[Idx].wbuf, My_Connections[Idx].wbuf + len, My_Connections[Idx].wdatalen );
|
||||||
|
@ -1000,7 +1151,11 @@ Read_Request( CONN_ID Idx )
|
||||||
assert( Idx > NONE );
|
assert( Idx > NONE );
|
||||||
assert( My_Connections[Idx].sock > NONE );
|
assert( My_Connections[Idx].sock > NONE );
|
||||||
|
|
||||||
if( READBUFFER_LEN - My_Connections[Idx].rdatalen - 2 < 0 )
|
#ifdef USE_ZLIB
|
||||||
|
if(( READBUFFER_LEN - My_Connections[Idx].rdatalen - 1 < 1 ) || ( ZREADBUFFER_LEN - My_Connections[Idx].zip.rdatalen < 1 ))
|
||||||
|
#else
|
||||||
|
if( READBUFFER_LEN - My_Connections[Idx].rdatalen - 1 < 1 )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/* Der Lesepuffer ist voll */
|
/* Der Lesepuffer ist voll */
|
||||||
Log( LOG_ERR, "Read buffer overflow (connection %d): %d bytes!", Idx, My_Connections[Idx].rdatalen );
|
Log( LOG_ERR, "Read buffer overflow (connection %d): %d bytes!", Idx, My_Connections[Idx].rdatalen );
|
||||||
|
@ -1008,7 +1163,18 @@ Read_Request( CONN_ID Idx )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = recv( My_Connections[Idx].sock, My_Connections[Idx].rbuf + My_Connections[Idx].rdatalen, READBUFFER_LEN - My_Connections[Idx].rdatalen - 2, 0 );
|
#ifdef USE_ZLIB
|
||||||
|
if( My_Connections[Idx].options & CONN_ZIP )
|
||||||
|
{
|
||||||
|
len = recv( My_Connections[Idx].sock, My_Connections[Idx].zip.rbuf + My_Connections[Idx].zip.rdatalen, ( ZREADBUFFER_LEN - My_Connections[Idx].zip.rdatalen ), 0 );
|
||||||
|
if( len > 0 ) My_Connections[Idx].zip.rdatalen += len;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
len = recv( My_Connections[Idx].sock, My_Connections[Idx].rbuf + My_Connections[Idx].rdatalen, READBUFFER_LEN - My_Connections[Idx].rdatalen - 1, 0 );
|
||||||
|
if( len > 0 ) My_Connections[Idx].rdatalen += len;
|
||||||
|
}
|
||||||
|
|
||||||
if( len == 0 )
|
if( len == 0 )
|
||||||
{
|
{
|
||||||
|
@ -1032,11 +1198,6 @@ Read_Request( CONN_ID Idx )
|
||||||
/* Connection-Statistik aktualisieren */
|
/* Connection-Statistik aktualisieren */
|
||||||
My_Connections[Idx].bytes_in += len;
|
My_Connections[Idx].bytes_in += len;
|
||||||
|
|
||||||
/* Lesebuffer updaten */
|
|
||||||
My_Connections[Idx].rdatalen += len;
|
|
||||||
assert( My_Connections[Idx].rdatalen < READBUFFER_LEN );
|
|
||||||
My_Connections[Idx].rbuf[My_Connections[Idx].rdatalen] = '\0';
|
|
||||||
|
|
||||||
/* Timestamp aktualisieren */
|
/* Timestamp aktualisieren */
|
||||||
My_Connections[Idx].lastdata = time( NULL );
|
My_Connections[Idx].lastdata = time( NULL );
|
||||||
|
|
||||||
|
@ -1056,56 +1217,73 @@ Handle_Buffer( CONN_ID Idx )
|
||||||
#endif
|
#endif
|
||||||
CHAR *ptr;
|
CHAR *ptr;
|
||||||
INT len, delta;
|
INT len, delta;
|
||||||
BOOLEAN action;
|
BOOLEAN action, result;
|
||||||
|
|
||||||
/* Eine komplette Anfrage muss mit CR+LF enden, vgl.
|
result = FALSE;
|
||||||
* RFC 2812. Haben wir eine? */
|
do
|
||||||
ptr = strstr( My_Connections[Idx].rbuf, "\r\n" );
|
|
||||||
|
|
||||||
if( ptr ) delta = 2;
|
|
||||||
#ifndef STRICT_RFC
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* Nicht RFC-konforme Anfrage mit nur CR oder LF? Leider
|
#ifdef USE_ZLIB
|
||||||
* machen soetwas viele Clients, u.a. "mIRC" :-( */
|
/* ggf. noch unkomprimiete Daten weiter entpacken */
|
||||||
ptr1 = strchr( My_Connections[Idx].rbuf, '\r' );
|
if( My_Connections[Idx].options & CONN_ZIP )
|
||||||
ptr2 = strchr( My_Connections[Idx].rbuf, '\n' );
|
{
|
||||||
delta = 1;
|
if( ! Unzip_Buffer( Idx )) return FALSE;
|
||||||
if( ptr1 && ptr2 ) ptr = ptr1 > ptr2 ? ptr2 : ptr1;
|
}
|
||||||
else if( ptr1 ) ptr = ptr1;
|
|
||||||
else if( ptr2 ) ptr = ptr2;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
action = FALSE;
|
|
||||||
if( ptr )
|
|
||||||
{
|
|
||||||
/* Ende der Anfrage wurde gefunden */
|
|
||||||
*ptr = '\0';
|
|
||||||
len = ( ptr - My_Connections[Idx].rbuf ) + delta;
|
|
||||||
if( len > ( COMMAND_LEN - 1 ))
|
|
||||||
{
|
|
||||||
/* Eine Anfrage darf(!) nicht laenger als 512 Zeichen
|
|
||||||
* (incl. CR+LF!) werden; vgl. RFC 2812. Wenn soetwas
|
|
||||||
* empfangen wird, wird der Client disconnectiert. */
|
|
||||||
Log( LOG_ERR, "Request too long (connection %d): %d bytes (max. %d expected)!", Idx, My_Connections[Idx].rdatalen, COMMAND_LEN - 1 );
|
|
||||||
Conn_Close( Idx, NULL, "Request too long", TRUE );
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( len > delta )
|
|
||||||
{
|
|
||||||
/* Es wurde ein Request gelesen */
|
|
||||||
if( ! Parse_Request( Idx, My_Connections[Idx].rbuf )) return FALSE;
|
|
||||||
else action = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Puffer anpassen */
|
|
||||||
My_Connections[Idx].rdatalen -= len;
|
|
||||||
memmove( My_Connections[Idx].rbuf, My_Connections[Idx].rbuf + len, My_Connections[Idx].rdatalen );
|
|
||||||
}
|
|
||||||
|
|
||||||
return action;
|
if( My_Connections[Idx].rdatalen < 1 ) break;
|
||||||
|
|
||||||
|
/* Eine komplette Anfrage muss mit CR+LF enden, vgl.
|
||||||
|
* RFC 2812. Haben wir eine? */
|
||||||
|
My_Connections[Idx].rbuf[My_Connections[Idx].rdatalen] = '\0';
|
||||||
|
ptr = strstr( My_Connections[Idx].rbuf, "\r\n" );
|
||||||
|
|
||||||
|
if( ptr ) delta = 2;
|
||||||
|
#ifndef STRICT_RFC
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Nicht RFC-konforme Anfrage mit nur CR oder LF? Leider
|
||||||
|
* machen soetwas viele Clients, u.a. "mIRC" :-( */
|
||||||
|
ptr1 = strchr( My_Connections[Idx].rbuf, '\r' );
|
||||||
|
ptr2 = strchr( My_Connections[Idx].rbuf, '\n' );
|
||||||
|
delta = 1;
|
||||||
|
if( ptr1 && ptr2 ) ptr = ptr1 > ptr2 ? ptr2 : ptr1;
|
||||||
|
else if( ptr1 ) ptr = ptr1;
|
||||||
|
else if( ptr2 ) ptr = ptr2;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
action = FALSE;
|
||||||
|
if( ptr )
|
||||||
|
{
|
||||||
|
/* Ende der Anfrage wurde gefunden */
|
||||||
|
*ptr = '\0';
|
||||||
|
len = ( ptr - My_Connections[Idx].rbuf ) + delta;
|
||||||
|
if( len > ( COMMAND_LEN - 1 ))
|
||||||
|
{
|
||||||
|
/* Eine Anfrage darf(!) nicht laenger als 512 Zeichen
|
||||||
|
* (incl. CR+LF!) werden; vgl. RFC 2812. Wenn soetwas
|
||||||
|
* empfangen wird, wird der Client disconnectiert. */
|
||||||
|
Log( LOG_ERR, "Request too long (connection %d): %d bytes (max. %d expected)!", Idx, My_Connections[Idx].rdatalen, COMMAND_LEN - 1 );
|
||||||
|
Conn_Close( Idx, NULL, "Request too long", TRUE );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( len > delta )
|
||||||
|
{
|
||||||
|
/* Es wurde ein Request gelesen */
|
||||||
|
if( ! Parse_Request( Idx, My_Connections[Idx].rbuf )) return FALSE;
|
||||||
|
else action = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Puffer anpassen */
|
||||||
|
My_Connections[Idx].rdatalen -= len;
|
||||||
|
memmove( My_Connections[Idx].rbuf, My_Connections[Idx].rbuf + len, My_Connections[Idx].rdatalen );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( action ) result = TRUE;
|
||||||
|
} while( action );
|
||||||
|
|
||||||
|
return result;
|
||||||
} /* Handle_Buffer */
|
} /* Handle_Buffer */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1342,6 +1520,16 @@ Init_Conn_Struct( LONG Idx )
|
||||||
My_Connections[Idx].bytes_in = 0;
|
My_Connections[Idx].bytes_in = 0;
|
||||||
My_Connections[Idx].bytes_out = 0;
|
My_Connections[Idx].bytes_out = 0;
|
||||||
My_Connections[Idx].flag = 0;
|
My_Connections[Idx].flag = 0;
|
||||||
|
My_Connections[Idx].options = 0;
|
||||||
|
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
My_Connections[Idx].zip.rbuf[0] = '\0';
|
||||||
|
My_Connections[Idx].zip.rdatalen = 0;
|
||||||
|
My_Connections[Idx].zip.wbuf[0] = '\0';
|
||||||
|
My_Connections[Idx].zip.wdatalen = 0;
|
||||||
|
My_Connections[Idx].zip.bytes_in = 0;
|
||||||
|
My_Connections[Idx].zip.bytes_out = 0;
|
||||||
|
#endif
|
||||||
} /* Init_Conn_Struct */
|
} /* Init_Conn_Struct */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1437,4 +1625,115 @@ Read_Resolver_Result( INT r_fd )
|
||||||
} /* Read_Resolver_Result */
|
} /* Read_Resolver_Result */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
|
||||||
|
LOCAL BOOLEAN
|
||||||
|
Zip_Buffer( CONN_ID Idx, CHAR *Data, INT Len )
|
||||||
|
{
|
||||||
|
/* Daten zum Komprimieren im "Kompressions-Puffer" sammeln.
|
||||||
|
* Es wird TRUE bei Erfolg, sonst FALSE geliefert. */
|
||||||
|
|
||||||
|
assert( Idx > NONE );
|
||||||
|
assert( Data != NULL );
|
||||||
|
assert( Len > 0 );
|
||||||
|
|
||||||
|
/* Ist noch Platz im Kompressions-Puffer? */
|
||||||
|
if( ZWRITEBUFFER_LEN - My_Connections[Idx].zip.wdatalen < Len + 50 )
|
||||||
|
{
|
||||||
|
/* Nein! Puffer zunaechst leeren ...*/
|
||||||
|
if( ! Zip_Flush( Idx )) return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Daten kopieren */
|
||||||
|
memmove( My_Connections[Idx].zip.wbuf + My_Connections[Idx].zip.wdatalen, Data, Len );
|
||||||
|
My_Connections[Idx].zip.wdatalen += Len;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} /* Zip_Buffer */
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL BOOLEAN
|
||||||
|
Zip_Flush( CONN_ID Idx )
|
||||||
|
{
|
||||||
|
/* Daten komprimieren und in Schreibpuffer kopieren.
|
||||||
|
* Es wird TRUE bei Erfolg, sonst FALSE geliefert. */
|
||||||
|
|
||||||
|
INT result, out_len;
|
||||||
|
z_stream *out;
|
||||||
|
|
||||||
|
out = &My_Connections[Idx].zip.out;
|
||||||
|
|
||||||
|
out->next_in = My_Connections[Idx].zip.wbuf;
|
||||||
|
out->avail_in = My_Connections[Idx].zip.wdatalen;
|
||||||
|
out->next_out = My_Connections[Idx].wbuf + My_Connections[Idx].wdatalen;
|
||||||
|
out->avail_out = WRITEBUFFER_LEN - My_Connections[Idx].wdatalen;
|
||||||
|
|
||||||
|
result = deflate( out, Z_SYNC_FLUSH );
|
||||||
|
if(( result != Z_OK ) || ( out->avail_in > 0 ))
|
||||||
|
{
|
||||||
|
Log( LOG_ALERT, "Compression error: code %d!?", result );
|
||||||
|
Conn_Close( Idx, "Compression error!", NULL, FALSE );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
out_len = WRITEBUFFER_LEN - My_Connections[Idx].wdatalen - out->avail_out;
|
||||||
|
My_Connections[Idx].wdatalen += out_len;
|
||||||
|
My_Connections[Idx].bytes_out += out_len;
|
||||||
|
My_Connections[Idx].zip.bytes_out += My_Connections[Idx].zip.wdatalen;
|
||||||
|
My_Connections[Idx].zip.wdatalen = 0;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} /* Zip_Flush */
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL BOOLEAN
|
||||||
|
Unzip_Buffer( CONN_ID Idx )
|
||||||
|
{
|
||||||
|
/* Daten entpacken und in Lesepuffer kopieren. Bei Fehlern
|
||||||
|
* wird FALSE geliefert, ansonsten TRUE. Der Fall, dass keine
|
||||||
|
* Daten mehr zu entpacken sind, ist _kein_ Fehler! */
|
||||||
|
|
||||||
|
INT result, in_len, out_len;
|
||||||
|
z_stream *in;
|
||||||
|
|
||||||
|
assert( Idx > NONE );
|
||||||
|
|
||||||
|
if( My_Connections[Idx].zip.rdatalen <= 0 ) return TRUE;
|
||||||
|
|
||||||
|
in = &My_Connections[Idx].zip.in;
|
||||||
|
|
||||||
|
in->next_in = My_Connections[Idx].zip.rbuf;
|
||||||
|
in->avail_in = My_Connections[Idx].zip.rdatalen;
|
||||||
|
in->next_out = My_Connections[Idx].rbuf + My_Connections[Idx].rdatalen;
|
||||||
|
in->avail_out = READBUFFER_LEN - My_Connections[Idx].rdatalen - 1;
|
||||||
|
|
||||||
|
result = inflate( in, Z_SYNC_FLUSH );
|
||||||
|
if( result != Z_OK )
|
||||||
|
{
|
||||||
|
Log( LOG_ALERT, "Decompression error: code %d!?", result );
|
||||||
|
Conn_Close( Idx, "Decompression error!", NULL, FALSE );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
in_len = My_Connections[Idx].zip.rdatalen - in->avail_in;
|
||||||
|
out_len = READBUFFER_LEN - My_Connections[Idx].rdatalen - 1 - in->avail_out;
|
||||||
|
My_Connections[Idx].rdatalen += out_len;
|
||||||
|
|
||||||
|
if( in->avail_in > 0 )
|
||||||
|
{
|
||||||
|
/* es konnten nicht alle Daten entpackt werden, vermutlich war
|
||||||
|
* im Ziel-Puffer kein Platz mehr. Umkopieren ... */
|
||||||
|
My_Connections[Idx].zip.rdatalen -= in_len;
|
||||||
|
memmove( My_Connections[Idx].zip.rbuf, My_Connections[Idx].zip.rbuf + in_len, My_Connections[Idx].zip.rdatalen );
|
||||||
|
}
|
||||||
|
else My_Connections[Idx].zip.rdatalen = 0;
|
||||||
|
My_Connections[Idx].zip.bytes_in += out_len;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} /* Unzip_Buffer */
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* -eof- */
|
/* -eof- */
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||||
*
|
*
|
||||||
* $Id: defines.h,v 1.36 2002/11/23 16:08:18 alex Exp $
|
* $Id: defines.h,v 1.37 2002/11/26 23:07:24 alex Exp $
|
||||||
*
|
*
|
||||||
* defines.h: (globale) Konstanten
|
* defines.h: (globale) Konstanten
|
||||||
*/
|
*/
|
||||||
|
@ -55,9 +55,14 @@
|
||||||
|
|
||||||
#define COMMAND_LEN 513 /* max. Laenge eines Befehls, vgl. RFC 2812, 3.2 */
|
#define COMMAND_LEN 513 /* max. Laenge eines Befehls, vgl. RFC 2812, 3.2 */
|
||||||
|
|
||||||
#define READBUFFER_LEN 2 * COMMAND_LEN /* Laenge des Lesepuffers je Verbindung (Bytes) */
|
#define READBUFFER_LEN 2048 /* Laenge des Lesepuffers je Verbindung (Bytes) */
|
||||||
#define WRITEBUFFER_LEN 4096 /* Laenge des Schreibpuffers je Verbindung (Bytes) */
|
#define WRITEBUFFER_LEN 4096 /* Laenge des Schreibpuffers je Verbindung (Bytes) */
|
||||||
|
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
#define ZREADBUFFER_LEN 1024 /* Laenge des Lesepuffers je Verbindung (Bytes) */
|
||||||
|
#define ZWRITEBUFFER_LEN 4096 /* Laenge des Schreibpuffers fuer Kompression (Bytes) */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PROTOVER "0210" /* implementierte Protokoll-Version (RFC 2813, 4.1.1) */
|
#define PROTOVER "0210" /* implementierte Protokoll-Version (RFC 2813, 4.1.1) */
|
||||||
#define PROTOIRC "-IRC" /* Protokoll-Suffix (RFC 2813, 4.1.1) */
|
#define PROTOIRC "-IRC" /* Protokoll-Suffix (RFC 2813, 4.1.1) */
|
||||||
#define PROTOIRCPLUS "-IRC+" /* Protokoll-Suffix fŸr IRC+-Protokoll */
|
#define PROTOIRCPLUS "-IRC+" /* Protokoll-Suffix fŸr IRC+-Protokoll */
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||||
*
|
*
|
||||||
* $Id: irc-login.c,v 1.22 2002/09/22 21:40:33 alex Exp $
|
* $Id: irc-login.c,v 1.23 2002/11/26 23:07:24 alex Exp $
|
||||||
*
|
*
|
||||||
* irc-login.c: Anmeldung und Abmeldung im IRC
|
* irc-login.c: Anmeldung und Abmeldung im IRC
|
||||||
*/
|
*/
|
||||||
|
@ -65,7 +65,7 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
|
||||||
}
|
}
|
||||||
else if((( Client_Type( Client ) == CLIENT_UNKNOWN ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER )) && (( Req->argc == 3 ) || ( Req->argc == 4 )))
|
else if((( Client_Type( Client ) == CLIENT_UNKNOWN ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER )) && (( Req->argc == 3 ) || ( Req->argc == 4 )))
|
||||||
{
|
{
|
||||||
CHAR c2, c4, *type, *impl, *serverver, *flags, *ptr;
|
CHAR c2, c4, *type, *impl, *serverver, *flags, *ptr, *ircflags;
|
||||||
INT protohigh, protolow;
|
INT protohigh, protolow;
|
||||||
|
|
||||||
/* noch nicht registrierte Server-Verbindung */
|
/* noch nicht registrierte Server-Verbindung */
|
||||||
|
@ -94,6 +94,10 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
|
||||||
if( strlen( Req->argv[1] ) > 4 ) type = &Req->argv[1][4];
|
if( strlen( Req->argv[1] ) > 4 ) type = &Req->argv[1][4];
|
||||||
else type = NULL;
|
else type = NULL;
|
||||||
|
|
||||||
|
/* IRC-Flags (nach RFC 2813) */
|
||||||
|
if( Req->argc >= 4 ) ircflags = Req->argv[3];
|
||||||
|
else ircflags = "";
|
||||||
|
|
||||||
/* Implementation, Version und ngIRCd-Flags */
|
/* Implementation, Version und ngIRCd-Flags */
|
||||||
impl = Req->argv[2];
|
impl = Req->argv[2];
|
||||||
ptr = strchr( impl, '|' );
|
ptr = strchr( impl, '|' );
|
||||||
|
@ -115,8 +119,12 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serverver = flags = "";
|
/* auf der anderen Seite laeuft ein Server, der
|
||||||
Log( LOG_INFO, "Connection %d: Peer announces itself as \"%s\" using protocol %d.%d.", Client_Conn( Client ), impl, protohigh, protolow );
|
* nur das Originalprotokoll unterstuetzt */
|
||||||
|
serverver = "";
|
||||||
|
if( strchr( ircflags, 'Z' )) flags = "Z";
|
||||||
|
else flags = "";
|
||||||
|
Log( LOG_INFO, "Connection %d: Peer announces itself as \"%s\" using protocol %d.%d (flags: \"%s\").", Client_Conn( Client ), impl, protohigh, protolow, flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
Client_SetType( Client, CLIENT_GOTPASSSERVER );
|
Client_SetType( Client, CLIENT_GOTPASSSERVER );
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||||
*
|
*
|
||||||
* $Id: irc-server.c,v 1.20 2002/11/19 12:50:20 alex Exp $
|
* $Id: irc-server.c,v 1.21 2002/11/26 23:07:24 alex Exp $
|
||||||
*
|
*
|
||||||
* irc-server.c: IRC-Befehle fuer Server-Links
|
* irc-server.c: IRC-Befehle fuer Server-Links
|
||||||
*/
|
*/
|
||||||
|
@ -47,6 +47,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
|
||||||
INT max_hops, i;
|
INT max_hops, i;
|
||||||
CHANNEL *chan;
|
CHANNEL *chan;
|
||||||
BOOLEAN ok;
|
BOOLEAN ok;
|
||||||
|
CONN_ID con;
|
||||||
|
|
||||||
assert( Client != NULL );
|
assert( Client != NULL );
|
||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
@ -86,9 +87,10 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
|
||||||
Client_SetID( Client, Req->argv[0] );
|
Client_SetID( Client, Req->argv[0] );
|
||||||
Client_SetHops( Client, 1 );
|
Client_SetHops( Client, 1 );
|
||||||
Client_SetInfo( Client, Req->argv[Req->argc - 1] );
|
Client_SetInfo( Client, Req->argv[Req->argc - 1] );
|
||||||
|
|
||||||
/* Meldet sich der Server bei uns an (d.h., bauen nicht wir
|
/* Meldet sich der Server bei uns an (d.h., bauen nicht wir
|
||||||
* selber die Verbindung zu einem anderen Server auf)? */
|
* selber die Verbindung zu einem anderen Server auf)? */
|
||||||
|
con = Client_Conn( Client );
|
||||||
if( Client_Token( Client ) != TOKEN_OUTBOUND )
|
if( Client_Token( Client ) != TOKEN_OUTBOUND )
|
||||||
{
|
{
|
||||||
/* Eingehende Verbindung: Unseren SERVER- und PASS-Befehl senden */
|
/* Eingehende Verbindung: Unseren SERVER- und PASS-Befehl senden */
|
||||||
|
@ -97,7 +99,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
|
||||||
else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo );
|
else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo );
|
||||||
if( ! ok )
|
if( ! ok )
|
||||||
{
|
{
|
||||||
Conn_Close( Client_Conn( Client ), "Unexpected server behavior!", NULL, FALSE );
|
Conn_Close( con, "Unexpected server behavior!", NULL, FALSE );
|
||||||
return DISCONNECTED;
|
return DISCONNECTED;
|
||||||
}
|
}
|
||||||
Client_SetIntroducer( Client, Client );
|
Client_SetIntroducer( Client, Client );
|
||||||
|
@ -110,10 +112,23 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
|
||||||
Client_SetToken( Client, atoi( Req->argv[1] ));
|
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 );
|
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 */
|
/* maximalen Hop Count ermitteln */
|
||||||
max_hops = 0;
|
max_hops = 0;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||||
*
|
*
|
||||||
* $Id: ngircd.c,v 1.61 2002/11/22 23:31:23 alex Exp $
|
* $Id: ngircd.c,v 1.62 2002/11/26 23:07:24 alex Exp $
|
||||||
*
|
*
|
||||||
* ngircd.c: Hier beginnt alles ;-)
|
* ngircd.c: Hier beginnt alles ;-)
|
||||||
*/
|
*/
|
||||||
|
@ -294,11 +294,17 @@ main( int argc, const char *argv[] )
|
||||||
* sind in doc/Protocol.txt beschrieben. */
|
* sind in doc/Protocol.txt beschrieben. */
|
||||||
#ifdef IRCPLUS
|
#ifdef IRCPLUS
|
||||||
sprintf( NGIRCd_ProtoID, "%s%s %s|%s:%s", PROTOVER, PROTOIRCPLUS, PACKAGE, VERSION, IRCPLUSFLAGS );
|
sprintf( NGIRCd_ProtoID, "%s%s %s|%s:%s", PROTOVER, PROTOIRCPLUS, PACKAGE, VERSION, IRCPLUSFLAGS );
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
strcat( NGIRCd_ProtoID, "Z" );
|
||||||
|
#endif
|
||||||
if( Conf_OperCanMode ) strcat( NGIRCd_ProtoID, "o" );
|
if( Conf_OperCanMode ) strcat( NGIRCd_ProtoID, "o" );
|
||||||
#else
|
#else
|
||||||
sprintf( NGIRCd_ProtoID, "%s%s %s|%s", PROTOVER, PROTOIRC, PACKAGE, VERSION );
|
sprintf( NGIRCd_ProtoID, "%s%s %s|%s", PROTOVER, PROTOIRC, PACKAGE, VERSION );
|
||||||
#endif
|
#endif
|
||||||
strcat( NGIRCd_ProtoID, " P" );
|
strcat( NGIRCd_ProtoID, " P" );
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
strcat( NGIRCd_ProtoID, "Z" );
|
||||||
|
#endif
|
||||||
Log( LOG_DEBUG, "Protocol and server ID is \"%s\".", NGIRCd_ProtoID );
|
Log( LOG_DEBUG, "Protocol and server ID is \"%s\".", NGIRCd_ProtoID );
|
||||||
|
|
||||||
/* Vordefinierte Channels anlegen */
|
/* Vordefinierte Channels anlegen */
|
||||||
|
@ -352,6 +358,10 @@ NGIRCd_VersionAddition( VOID )
|
||||||
if( txt[0] ) strcat( txt, "+" );
|
if( txt[0] ) strcat( txt, "+" );
|
||||||
strcat( txt, "SYSLOG" );
|
strcat( txt, "SYSLOG" );
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
if( txt[0] ) strcat( txt, "+" );
|
||||||
|
strcat( txt, "ZLIB" );
|
||||||
|
#endif
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if( txt[0] ) strcat( txt, "+" );
|
if( txt[0] ) strcat( txt, "+" );
|
||||||
strcat( txt, "DEBUG" );
|
strcat( txt, "DEBUG" );
|
||||||
|
|
Loading…
Reference in New Issue