#include "portab.h"
-static char UNUSED id[] = "$Id: client.c,v 1.81 2005/05/17 23:18:54 alex Exp $";
+static char UNUSED id[] = "$Id: client.c,v 1.84 2005/06/12 16:39:42 alex Exp $";
#include "imp.h"
#include <assert.h>
if( ! client ) return NULL;
/* Initialisieren */
+ client->starttime = time(NULL);
client->conn_id = Idx;
client->introducer = Introducer;
client->topserver = TopServer;
if( ! txt ) txt = "Reason unknown.";
/* Netz-Split-Nachricht vorbereiten (noch nicht optimal) */
- if( Client->type == CLIENT_SERVER ) snprintf( msg, sizeof( msg ), "%s: lost server %s", This_Server->id, Client->id );
+ if( Client->type == CLIENT_SERVER ) {
+ strlcpy(msg, This_Server->id, sizeof (msg));
+ strlcat(msg, " ", sizeof (msg));
+ strlcat(msg, Client->id, sizeof (msg));
+ }
last = NULL;
c = My_Clients;
} /* Client_GetLastWhowasIndex */
+/**
+ * Get the start time of this client.
+ * The result is the start time in seconds since 1970-01-01, as reported
+ * by the C function time(NULL).
+ */
+GLOBAL time_t
+Client_StartTime(CLIENT *Client)
+{
+ assert( Client != NULL );
+ return Client->starttime;
+} /* Client_Uptime */
+
+
LOCAL long
Count( CLIENT_TYPE Type )
{
/**
* Register client in My_Whowas structure for further recall by WHOWAS.
+ * Note: Only clients that have been connected at least 30 seconds will be
+ * registered to prevent automated IRC bots to "destroy" a nice server
+ * history database.
*/
GLOBAL void
Client_RegisterWhowas( CLIENT *Client )
assert( Client != NULL );
+ /* Don't register clients that were connected less than 30 seconds. */
+ if( time(NULL) - Client->starttime < 30 )
+ return;
+
slot = Last_Whowas + 1;
if( slot >= MAX_WHOWAS || slot < 0 ) slot = 0;