* 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.74 2002/09/26 16:11:26 alex Exp $
+ * $Id: conn.c,v 1.80 2002/10/09 17:07:22 alex Exp $
*
* connect.h: Verwaltung aller Netz-Verbindungen ("connections")
*/
time_t lastping; /* Letzter PING */
time_t lastprivmsg; /* Letzte PRIVMSG */
time_t delaytime; /* Nicht beachten bis ("penalty") */
+ LONG bytes_in, bytes_out; /* Counter fuer Statistik */
} CONNECTION;
assert( Idx >= 0 );
assert( My_Connections[Idx].sock > NONE );
+ c = Client_GetFromConn( Idx );
+
if( InformClient )
{
+ /* Statistik an Client melden, wenn User */
+ if(( c != NULL ) && ( Client_Type( c ) == CLIENT_USER ))
+ {
+ Conn_WriteStr( Idx, "NOTICE %s :%sConnection statistics: %.1f kb received, %.1f kb sent.", Client_ThisServer( ), NOTICE_TXTPREFIX, (DOUBLE)My_Connections[Idx].bytes_in / 1024, (DOUBLE)My_Connections[Idx].bytes_out / 1024 );
+ }
+
+ /* ERROR an Client schicken (von RFC so vorgesehen!) */
if( FwdMsg ) Conn_WriteStr( Idx, "ERROR :%s", FwdMsg );
else Conn_WriteStr( Idx, "ERROR :Closing connection." );
if( My_Connections[Idx].sock == NONE ) return;
Log( LOG_INFO, "Connection %d with %s:%d closed.", Idx, inet_ntoa( My_Connections[Idx].addr.sin_addr ), ntohs( My_Connections[Idx].addr.sin_port ));
}
- c = Client_GetFromConn( Idx );
if( c ) Client_Destroy( c, LogMsg, FwdMsg, TRUE );
if( My_Connections[Idx].res_stat )
free( My_Connections[Idx].res_stat );
}
- /* Bei Server-Verbindungen lasttry-Zeitpunkt so setzen, dass
- * der naechste Verbindungsversuch in RECONNECT_DELAY Sekunden
- * gestartet wird. */
- if(( My_Connections[Idx].our_server >= 0 ) && ( Conf_Server[My_Connections[Idx].our_server].lasttry < time( NULL )))
+ /* Startzeit des naechsten Connect-Versuchs modifizieren? */
+ if(( My_Connections[Idx].our_server >= 0 ) && ( Conf_Server[My_Connections[Idx].our_server].lasttry < time( NULL ) - Conf_ConnectRetry ))
{
- /* Okay, die Verbindung stand schon "genuegend lange" */
+ /* Okay, die Verbindung stand schon "genuegend lange":
+ * lasttry-Zeitpunkt so setzen, dass der naechste
+ * Verbindungsversuch in RECONNECT_DELAY Sekunden
+ * gestartet wird. */
Conf_Server[My_Connections[Idx].our_server].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
}
return FALSE;
}
+ /* Connection-Statistik aktualisieren */
+ My_Connections[Idx].bytes_out += len;
+
/* Puffer anpassen */
My_Connections[Idx].wdatalen -= len;
memmove( My_Connections[Idx].wbuf, My_Connections[Idx].wbuf + len, My_Connections[Idx].wdatalen );
if( s )
{
/* Sub-Prozess wurde asyncron gestartet */
+ Conn_WriteStr( idx, "NOTICE AUTH :%sLooking up your hostname ...", NOTICE_TXTPREFIX );
My_Connections[idx].res_stat = s;
}
else
return;
}
+ /* Connection-Statistik aktualisieren */
+ My_Connections[Idx].bytes_in += len;
+
/* Lesebuffer updaten */
My_Connections[Idx].rdatalen += len;
assert( My_Connections[Idx].rdatalen < READBUFFER_LEN );
My_Connections[Idx].lastping = 0;
My_Connections[Idx].lastprivmsg = time( NULL );
My_Connections[Idx].delaytime = 0;
+ My_Connections[Idx].bytes_in = 0;
+ My_Connections[Idx].bytes_out = 0;
} /* Init_Conn_Struct */
FD_CLR( r_fd, &Resolver_FDs );
/* Anfrage vom Parent lesen */
- len = read( r_fd, result, HOST_LEN);
+ len = read( r_fd, result, HOST_LEN - 1 );
if( len < 0 )
{
/* Fehler beim Lesen aus der Pipe */
assert( c != NULL );
strcpy( My_Connections[i].host, result );
Client_SetHostname( c, result );
+
+ Conn_WriteStr( i, "NOTICE AUTH :%sGot your hostname.", NOTICE_TXTPREFIX );
}
else
{