commit - dbd0a23994032d3e552ef730872b1bc86f16d17d
commit + 79809118a30e8160773bf0f521100339efff6000
blob - 50dd469c6ec65af7f92f3bfa4db323962e00f1e8
blob + b4ba8ae50bd1123a043b006601e5ae07b550f436
--- src/ngircd/client.c
+++ src/ngircd/client.c
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: client.c,v 1.23 2002/01/05 23:26:05 alex Exp $
+ * $Id: client.c,v 1.24 2002/01/06 15:18:14 alex Exp $
*
* client.c: Management aller Clients
*
* Server gewesen, so existiert eine entsprechende CONNECTION-Struktur.
*
* $Log: client.c,v $
+ * Revision 1.24 2002/01/06 15:18:14 alex
+ * - Loglevel und Meldungen nochmals geaendert. Level passen nun besser.
+ *
* Revision 1.23 2002/01/05 23:26:05 alex
* - Vorbereitungen fuer Ident-Abfragen in Client-Strukturen.
*
#include "client.h"
#include <imp.h>
+#include "ngircd.h"
#include "channel.h"
#include "conf.h"
#include "conn.h"
CLIENT *c, *next;
INT cnt;
- Client_Destroy( This_Server );
+ Client_Destroy( This_Server, "Server going down.", NULL );
cnt = 0;
c = My_Clients;
c = next;
}
if( cnt ) Log( LOG_INFO, "Freed %d client structure%s.", cnt, cnt == 1 ? "" : "s" );
-} /* Client Exit */
+} /* Client_Exit */
GLOBAL CLIENT *Client_ThisServer( VOID )
} /* Client_New */
-GLOBAL VOID Client_Destroy( CLIENT *Client )
+GLOBAL VOID Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg )
{
/* Client entfernen. */
CLIENT *last, *c;
+ CHAR *txt;
assert( Client != NULL );
+ if( LogMsg ) txt = LogMsg;
+ else txt = FwdMsg;
+ if( ! txt ) txt = "Reason unknown.";
+
last = NULL;
c = My_Clients;
while( c )
{
if(( Client->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c != Client ))
{
- Client_Destroy( c );
+ Client_Destroy( c, LogMsg, FwdMsg );
last = NULL;
c = My_Clients;
continue;
if( c->conn_id != NONE )
{
/* Ein lokaler User. Andere Server informieren! */
- Log( LOG_NOTICE, "User \"%s\" exited (connection %d).", c->id, c->conn_id );
- IRC_WriteStrServersPrefix( NULL, c, "QUIT :" );
+ Log( LOG_NOTICE, "User \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt );
+
+ if( FwdMsg ) IRC_WriteStrServersPrefix( NULL, c, "QUIT :%s", FwdMsg );
+ else IRC_WriteStrServersPrefix( NULL, c, "QUIT :" );
}
- else Log( LOG_DEBUG, "User \"%s\" exited.", c->id );
+ else
+ {
+ Log( LOG_DEBUG, "User \"%s\" unregistered: %s", c->id, txt );
+ }
}
- else if( c->type == CLIENT_SERVER ) Log( LOG_NOTICE, "Server \"%s\" exited.", c->id );
- else Log( LOG_NOTICE, "Unknown client \"%s\" exited.", c->id );
+ else if( c->type == CLIENT_SERVER )
+ {
+ if( c != This_Server ) Log( LOG_NOTICE, "Server \"%s\" unregistered: %s", c->id, txt );
+ }
+ else Log( LOG_NOTICE, "Unknown client \"%s\" unregistered: %s", c->id, txt );
free( c );
break;
{
/* die Server-ID gibt es bereits */
sprintf( str, "ID \"%s\" already registered!", ID );
- Log( LOG_ALERT, "%s (on connection %d)", str, Client->conn_id );
- Conn_Close( Client->conn_id, str );
+ Log( LOG_ERR, "%s (on connection %d)", str, Client->conn_id );
+ Conn_Close( Client->conn_id, str, str, TRUE );
return FALSE;
}
c = c->next;
blob - 4b159053e5393403cb6a903915798d8845ccba9b
blob + 2cddb54475b98c9754409da792129edf2c855fcc
--- src/ngircd/client.h
+++ src/ngircd/client.h
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: client.h,v 1.16 2002/01/05 23:26:05 alex Exp $
+ * $Id: client.h,v 1.17 2002/01/06 15:18:14 alex Exp $
*
* client.h: Konfiguration des ngircd (Header)
*
* $Log: client.h,v $
+ * Revision 1.17 2002/01/06 15:18:14 alex
+ * - Loglevel und Meldungen nochmals geaendert. Level passen nun besser.
+ *
* Revision 1.16 2002/01/05 23:26:05 alex
* - Vorbereitungen fuer Ident-Abfragen in Client-Strukturen.
*
GLOBAL CLIENT *Client_NewRemoteUser( CLIENT *Introducer, CHAR *Nick, INT Hops, CHAR *User, CHAR *Hostname, INT Token, CHAR *Modes, CHAR *Info, BOOLEAN Idented );
GLOBAL CLIENT *Client_New( CONN_ID Idx, CLIENT *Introducer, INT Type, CHAR *ID, CHAR *User, CHAR *Hostname, CHAR *Info, INT Hops, INT Token, CHAR *Modes, BOOLEAN Idented );
-GLOBAL VOID Client_Destroy( CLIENT *Client );
+GLOBAL VOID Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg );
GLOBAL CLIENT *Client_ThisServer( VOID );
blob - 989a65990642cdc6fca1a3c8836037953b461212
blob + e0bd7b457151e5cec6981e5ab003447decd46937
--- src/ngircd/conn.c
+++ src/ngircd/conn.c
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: conn.c,v 1.32 2002/01/05 23:25:25 alex Exp $
+ * $Id: conn.c,v 1.33 2002/01/06 15:18:14 alex Exp $
*
* connect.h: Verwaltung aller Netz-Verbindungen ("connections")
*
* $Log: conn.c,v $
+ * Revision 1.33 2002/01/06 15:18:14 alex
+ * - Loglevel und Meldungen nochmals geaendert. Level passen nun besser.
+ *
* Revision 1.32 2002/01/05 23:25:25 alex
* - Vorbereitungen fuer Ident-Abfragen bei neuen Client-Strukturen.
*
INT i;
/* Sockets schliessen */
+ Log( LOG_DEBUG, "Shutting down all connections ..." );
for( i = 0; i < My_Max_Fd + 1; i++ )
{
if( FD_ISSET( i, &My_Sockets ))
{
if( My_Connections[idx].sock == i ) break;
}
- if( idx < MAX_CONNECTIONS ) Conn_Close( idx, "Server going down ..." );
+ if( idx < MAX_CONNECTIONS ) Conn_Close( idx, NULL, "Server going down", TRUE );
else if( FD_ISSET( i, &My_Listeners ))
{
close( i );
- Log( LOG_INFO, "Listening socket %d closed.", i );
+ Log( LOG_DEBUG, "Listening socket %d closed.", i );
}
else
{
sock = socket( PF_INET, SOCK_STREAM, 0);
if( sock < 0 )
{
- Log( LOG_ALERT, "Can't create socket: %s!", strerror( errno ));
+ Log( LOG_CRIT, "Can't create socket: %s!", strerror( errno ));
return FALSE;
}
/* Socket-Optionen setzen */
if( fcntl( sock, F_SETFL, O_NONBLOCK ) != 0 )
{
- Log( LOG_ALERT, "Can't enable non-blocking mode: %s!", strerror( errno ));
+ Log( LOG_CRIT, "Can't enable non-blocking mode: %s!", strerror( errno ));
close( sock );
return FALSE;
}
if( setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, &on, (socklen_t)sizeof( on )) != 0)
{
- Log( LOG_CRIT, "Can't set socket options: %s!", strerror( errno ));
+ Log( LOG_ERR, "Can't set socket options: %s!", strerror( errno ));
/* dieser Fehler kann ignoriert werden. */
}
/* an Port binden */
if( bind( sock, (struct sockaddr *)&addr, (socklen_t)sizeof( addr )) != 0 )
{
- Log( LOG_ALERT, "Can't bind socket: %s!", strerror( errno ));
+ Log( LOG_CRIT, "Can't bind socket: %s!", strerror( errno ));
close( sock );
return FALSE;
}
/* in "listen mode" gehen :-) */
if( listen( sock, 10 ) != 0 )
{
- Log( LOG_ALERT, "Can't listen on soecket: %s!", strerror( errno ));
+ Log( LOG_CRIT, "Can't listen on soecket: %s!", strerror( errno ));
close( sock );
return FALSE;
}
{
if( errno != EINTR )
{
- Log( LOG_ALERT, "select(): %s!", strerror( errno ));
+ Log( LOG_EMERG, "select(): %s!", strerror( errno ));
Log( LOG_ALERT, PACKAGE" exiting due to fatal errors!" );
exit( 1 );
}
va_start( ap, Format );
if( vsnprintf( buffer, COMMAND_LEN - 2, Format, ap ) == COMMAND_LEN - 2 )
{
- Log( LOG_ALERT, "String too long to send (connection %d)!", Idx );
- Conn_Close( Idx, "Server error: String too long to send!" );
+ Log( LOG_CRIT, "Text too long to send (connection %d)!", Idx );
+ Conn_Close( Idx, "Text too long to send!", NULL, FALSE );
return FALSE;
}
{
/* der Puffer ist dummerweise voll ... */
Log( LOG_NOTICE, "Write buffer overflow (connection %d)!", Idx );
- Conn_Close( Idx, NULL );
+ Conn_Close( Idx, "Write buffer overflow!", NULL, FALSE );
return FALSE;
}
} /* Conn_Write */
-GLOBAL VOID Conn_Close( CONN_ID Idx, CHAR *Msg )
+GLOBAL VOID Conn_Close( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient )
{
/* Verbindung schliessen. Evtl. noch von Resolver
* Sub-Prozessen offene Pipes werden geschlossen. */
assert( Idx >= 0 );
assert( My_Connections[Idx].sock > NONE );
- if( Msg )
+ if( InformClient )
{
- Conn_WriteStr( Idx, "ERROR :%s", Msg );
+ if( FwdMsg ) Conn_WriteStr( Idx, "ERROR :%s", FwdMsg );
+ else Conn_WriteStr( Idx, "ERROR :Closing connection." );
if( My_Connections[Idx].sock == NONE ) return;
}
}
c = Client_GetFromConn( Idx );
- if( c ) Client_Destroy( c );
+ if( c ) Client_Destroy( c, LogMsg, FwdMsg );
if( My_Connections[Idx].res_stat )
{
/* Fehler! */
if( errno != EINTR )
{
- Log( LOG_ALERT, "select(): %s!", strerror( errno ));
- Conn_Close( Idx, NULL );
+ Log( LOG_ALERT, "select() failed: %s!", strerror( errno ));
+ Conn_Close( Idx, "Server error!", NULL, FALSE );
return FALSE;
}
}
if( len < 0 )
{
/* Oops, ein Fehler! */
- Log( LOG_ALERT, "Write error (buffer) on connection %d: %s!", Idx, strerror( errno ));
- Conn_Close( Idx, NULL );
+ Log( LOG_ERR, "Write error (buffer) on connection %d: %s!", Idx, strerror( errno ));
+ Conn_Close( Idx, "Write error (buffer)!", NULL, FALSE );
return FALSE;
}
if( READBUFFER_LEN - My_Connections[Idx].rdatalen - 2 < 0 )
{
/* Der Lesepuffer ist voll */
- Log( LOG_ALERT, "Read buffer overflow (connection %d): %d bytes!", Idx, My_Connections[Idx].rdatalen );
- Conn_Close( Idx, "Read buffer overflow!" );
+ Log( LOG_ERR, "Read buffer overflow (connection %d): %d bytes!", Idx, My_Connections[Idx].rdatalen );
+ Conn_Close( Idx, "Read buffer overflow!", NULL, FALSE );
return;
}
{
/* Socket wurde geschlossen */
Log( LOG_INFO, "%s:%d is closing the connection ...", inet_ntoa( My_Connections[Idx].addr.sin_addr ), ntohs( My_Connections[Idx].addr.sin_port));
- Conn_Close( Idx, NULL );
+ Conn_Close( Idx, "Socket closed.", NULL, FALSE );
return;
}
if( len < 0 )
{
/* Fehler beim Lesen */
- Log( LOG_ALERT, "Read error on connection %d: %s!", Idx, strerror( errno ));
- Conn_Close( Idx, NULL );
+ Log( LOG_ERR, "Read error on connection %d: %s!", Idx, strerror( errno ));
+ Conn_Close( Idx, "Read error!", NULL, FALSE );
return;
}
/* 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_ALERT, "Request too long (connection %d): %d bytes!", Idx, My_Connections[Idx].rdatalen );
- Conn_Close( Idx, "Request too long!" );
+ Log( LOG_ERR, "Request too long (connection %d): %d bytes!", Idx, My_Connections[Idx].rdatalen );
+ Conn_Close( Idx, NULL, "Request too long", TRUE );
return;
}
if( My_Connections[i].lastping < time( NULL ) - Conf_PongTimeout )
{
/* Timeout */
- Log( LOG_INFO, "Connection %d: PING timeout.", i );
- Conn_Close( i, "PING timeout" );
+ Log( LOG_DEBUG, "Connection %d: Ping timeout.", i );
+ Conn_Close( i, NULL, "Ping timeout", TRUE );
}
}
else if( My_Connections[i].lastdata < time( NULL ) - Conf_PingTimeout )
{
/* Timeout */
Log( LOG_INFO, "Connection %d: Timeout.", i );
- Conn_Close( i, "Timeout" );
+ Conn_Close( i, NULL, "Timeout", TRUE );
}
}
}
if ( new_sock < 0 )
{
Init_Conn_Struct( Idx );
- Log( LOG_ALERT, "Can't create socket: %s!", strerror( errno ));
+ Log( LOG_CRIT, "Can't create socket: %s!", strerror( errno ));
return;
}
if( connect( new_sock, (struct sockaddr *)&new_addr, sizeof( new_addr )) < 0)
{
close( new_sock );
Init_Conn_Struct( Idx );
- Log( LOG_ALERT, "Can't connect socket: %s!", strerror( errno ));
+ Log( LOG_CRIT, "Can't connect socket: %s!", strerror( errno ));
return;
}
s = malloc( sizeof( RES_STAT ));
if( ! s )
{
- Log( LOG_ALERT, "Resolver: Can't alloc memory!" );
+ Log( LOG_EMERG, "Resolver: Can't allocate memory!" );
return NULL;
}
{
/* Fehler */
free( s );
- Log( LOG_ALERT, "Resolver: Can't fork: %s!", strerror( errno ));
+ Log( LOG_CRIT, "Resolver: Can't fork: %s!", strerror( errno ));
return NULL;
}
} /* ResolveAddr */
s = malloc( sizeof( RES_STAT ));
if( ! s )
{
- Log( LOG_ALERT, "Resolver: Can't alloc memory!" );
+ Log( LOG_EMERG, "Resolver: Can't allocate memory!" );
return NULL;
}
{
/* Fehler */
free( s );
- Log( LOG_ALERT, "Resolver: Can't fork: %s!", strerror( errno ));
+ Log( LOG_CRIT, "Resolver: Can't fork: %s!", strerror( errno ));
return NULL;
}
} /* ResolveName */
/* Antwort an Parent schreiben */
if( write( w_fd, hostname, strlen( hostname ) + 1 ) != ( strlen( hostname ) + 1 ))
{
- Log_Resolver( LOG_ALERT, "Resolver: Can't write to parent: %s!", strerror( errno ));
+ Log_Resolver( LOG_CRIT, "Resolver: Can't write to parent: %s!", strerror( errno ));
close( w_fd );
return;
}
/* Antwort an Parent schreiben */
if( write( w_fd, ip, strlen( ip ) + 1 ) != ( strlen( ip ) + 1 ))
{
- Log_Resolver( LOG_ALERT, "Resolver: Can't write to parent: %s!", strerror( errno ));
+ Log_Resolver( LOG_CRIT, "Resolver: Can't write to parent: %s!", strerror( errno ));
close( w_fd );
return;
}
{
/* Fehler beim Lesen aus der Pipe */
close( r_fd );
- Log( LOG_ALERT, "Resolver: Can't read result: %s!", strerror( errno ));
+ Log( LOG_CRIT, "Resolver: Can't read result: %s!", strerror( errno ));
return;
}
result[len] = '\0';
blob - 2e0ac8eb4644285e0f3d62e9c7a6bd8404086b3f
blob + 8344b29159ef2adb36230c1afd8eb66660d89b46
--- src/ngircd/conn.h
+++ src/ngircd/conn.h
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: conn.h,v 1.9 2002/01/02 02:44:36 alex Exp $
+ * $Id: conn.h,v 1.10 2002/01/06 15:18:15 alex Exp $
*
* conn.h: Verwaltung aller Netz-Verbindungen ("connections") (Header)
*
* $Log: conn.h,v $
+ * Revision 1.10 2002/01/06 15:18:15 alex
+ * - Loglevel und Meldungen nochmals geaendert. Level passen nun besser.
+ *
* Revision 1.9 2002/01/02 02:44:36 alex
* - neue Defines fuer max. Anzahl Server und Operatoren.
*
GLOBAL BOOLEAN Conn_Write( CONN_ID Idx, CHAR *Data, INT Len );
GLOBAL BOOLEAN Conn_WriteStr( CONN_ID Idx, CHAR *Format, ... );
-GLOBAL VOID Conn_Close( CONN_ID Idx, CHAR *Msg );
+GLOBAL VOID Conn_Close( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient );
GLOBAL VOID Conn_UpdateIdle( CONN_ID Idx );
GLOBAL INT32 Conn_GetIdle( CONN_ID Idx );