]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/client.c
Only register clients that have been connected at least 30 sec. in WHOIS database.
[ngircd-alex.git] / src / ngircd / client.c
index 7cb81a7825dd5fd4909f047e86f6914b05ae1920..2a7f10bae466926ebcff79ed6f90d52f80e1b812 100644 (file)
@@ -17,7 +17,7 @@
 
 #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>
@@ -172,6 +172,7 @@ Client_New( CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer, int Type, char *
        if( ! client ) return NULL;
 
        /* Initialisieren */
+       client->starttime = time(NULL);
        client->conn_id = Idx;
        client->introducer = Introducer;
        client->topserver = TopServer;
@@ -214,7 +215,11 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
        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;
@@ -1017,6 +1022,19 @@ Client_GetLastWhowasIndex( void )
 } /* 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 )
 {
@@ -1124,6 +1142,9 @@ Adjust_Counters( CLIENT *Client )
 
 /**
  * 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 )
@@ -1132,6 +1153,10 @@ 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;