2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2005 by Alexander Barton (alex@barton.de)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
20 static char UNUSED id[] = "$Id: client.c,v 1.90 2006/03/24 23:25:38 fw Exp $";
43 #include "irc-write.h"
50 #define GETID_LEN (CLIENT_NICK_LEN-1) + 1 + (CLIENT_USER_LEN-1) + 1 + (CLIENT_HOST_LEN-1) + 1
53 static CLIENT *This_Server, *My_Clients;
54 static char GetID_Buffer[GETID_LEN];
56 static WHOWAS My_Whowas[MAX_WHOWAS];
57 static int Last_Whowas = -1;
60 static long Count PARAMS(( CLIENT_TYPE Type ));
61 static long MyCount PARAMS(( CLIENT_TYPE Type ));
63 static CLIENT *New_Client_Struct PARAMS(( void ));
64 static void Generate_MyToken PARAMS(( CLIENT *Client ));
65 static void Adjust_Counters PARAMS(( CLIENT *Client ));
67 static CLIENT *Init_New_Client PARAMS((CONN_ID Idx, CLIENT *Introducer,
68 CLIENT *TopServer, int Type, char *ID, char *User, char *Hostname,
69 char *Info, int Hops, int Token, char *Modes, bool Idented));
71 #ifndef Client_DestroyNow
72 GLOBAL void Client_DestroyNow PARAMS((CLIENT *Client ));
76 long Max_Users = 0, My_Max_Users = 0;
84 This_Server = New_Client_Struct( );
87 Log( LOG_EMERG, "Can't allocate client structure for server! Going down." );
88 Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
92 /* Client-Struktur dieses Servers */
93 This_Server->next = NULL;
94 This_Server->type = CLIENT_SERVER;
95 This_Server->conn_id = NONE;
96 This_Server->introducer = This_Server;
97 This_Server->mytoken = 1;
98 This_Server->hops = 0;
100 gethostname( This_Server->host, CLIENT_HOST_LEN );
101 h = gethostbyname( This_Server->host );
102 if( h ) strlcpy( This_Server->host, h->h_name, sizeof( This_Server->host ));
104 Client_SetID( This_Server, Conf_ServerName );
105 Client_SetInfo( This_Server, Conf_ServerInfo );
107 My_Clients = This_Server;
109 memset( &My_Whowas, 0, sizeof( My_Whowas ));
119 if( NGIRCd_SignalRestart ) Client_Destroy( This_Server, "Server going down (restarting).", NULL, false );
120 else Client_Destroy( This_Server, "Server going down.", NULL, false );
127 next = (CLIENT *)c->next;
131 if( cnt ) Log( LOG_INFO, "Freed %d client structure%s.", cnt, cnt == 1 ? "" : "s" );
136 Client_ThisServer( void )
139 } /* Client_ThisServer */
143 * Initialize new local client; wrapper function for Init_New_Client().
144 * @return New CLIENT structure.
147 Client_NewLocal(CONN_ID Idx, char *Hostname, int Type, bool Idented)
149 return Init_New_Client(Idx, This_Server, NULL, Type, NULL, NULL,
150 Hostname, NULL, 0, 0, NULL, Idented);
151 } /* Client_NewLocal */
155 * Initialize new remote server; wrapper function for Init_New_Client().
156 * @return New CLIENT structure.
159 Client_NewRemoteServer(CLIENT *Introducer, char *Hostname, CLIENT *TopServer,
160 int Hops, int Token, char *Info, bool Idented)
162 return Init_New_Client(NONE, Introducer, TopServer, CLIENT_SERVER,
163 Hostname, NULL, Hostname, Info, Hops, Token, NULL, Idented);
164 } /* Client_NewRemoteServer */
168 * Initialize new remote client; wrapper function for Init_New_Client().
169 * @return New CLIENT structure.
172 Client_NewRemoteUser(CLIENT *Introducer, char *Nick, int Hops, char *User,
173 char *Hostname, int Token, char *Modes, char *Info, bool Idented)
175 return Init_New_Client(NONE, Introducer, NULL, CLIENT_USER, Nick,
176 User, Hostname, Info, Hops, Token, Modes, Idented);
177 } /* Client_NewRemoteUser */
181 * Initialize new client and set up the given parameters like client type,
182 * user name, host name, introducing server etc. ...
183 * @return New CLIENT structure.
186 Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer,
187 int Type, char *ID, char *User, char *Hostname, char *Info, int Hops,
188 int Token, char *Modes, bool Idented)
192 assert( Idx >= NONE );
193 assert( Introducer != NULL );
194 assert( Hostname != NULL );
196 client = New_Client_Struct( );
197 if( ! client ) return NULL;
200 client->starttime = time(NULL);
201 client->conn_id = Idx;
202 client->introducer = Introducer;
203 client->topserver = TopServer;
205 if( ID ) Client_SetID( client, ID );
206 if( User ) Client_SetUser( client, User, Idented );
207 if( Hostname ) Client_SetHostname( client, Hostname );
208 if( Info ) Client_SetInfo( client, Info );
210 client->token = Token;
211 if( Modes ) Client_SetModes( client, Modes );
212 if( Type == CLIENT_SERVER ) Generate_MyToken( client );
214 /* ist der User away? */
215 if( strchr( client->modes, 'a' )) strlcpy( client->away, DEFAULT_AWAY_MSG, sizeof( client->away ));
218 client->next = (POINTER *)My_Clients;
221 /* Adjust counters */
222 Adjust_Counters( client );
225 } /* Init_New_Client */
229 Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
231 /* Client entfernen. */
234 char msg[LINE_LEN], *txt;
236 assert( Client != NULL );
238 if( LogMsg ) txt = LogMsg;
240 if( ! txt ) txt = "Reason unknown.";
242 /* Netz-Split-Nachricht vorbereiten (noch nicht optimal) */
243 if( Client->type == CLIENT_SERVER ) {
244 strlcpy(msg, This_Server->id, sizeof (msg));
245 strlcat(msg, " ", sizeof (msg));
246 strlcat(msg, Client->id, sizeof (msg));
253 if(( Client->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c != Client ))
255 /* der Client, der geloescht wird ist ein Server. Der Client, den wir gerade
256 * pruefen, ist ein Child von diesem und muss daher auch entfernt werden */
257 Client_Destroy( c, NULL, msg, false );
264 /* Wir haben den Client gefunden: entfernen */
265 if( last ) last->next = c->next;
266 else My_Clients = (CLIENT *)c->next;
268 if( c->type == CLIENT_USER )
270 if( c->conn_id != NONE )
272 /* Ein lokaler User */
273 Log( LOG_NOTICE, "User \"%s\" unregistered (connection %d): %s", Client_Mask( c ), c->conn_id, txt );
277 /* Alle andere Server informieren! */
278 if( FwdMsg ) IRC_WriteStrServersPrefix( NULL, c, "QUIT :%s", FwdMsg );
279 else IRC_WriteStrServersPrefix( NULL, c, "QUIT :" );
285 Log( LOG_DEBUG, "User \"%s\" unregistered: %s", Client_Mask( c ), txt );
289 /* Andere Server informieren, ausser denen, die "in
290 * Richtung dem liegen", auf dem der User registriert
291 * ist. Von denen haben wir das QUIT ja wohl bekommen. */
292 if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :%s", FwdMsg );
293 else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :" );
297 /* Unregister client from channels */
298 Channel_Quit( c, FwdMsg ? FwdMsg : c->id );
300 /* Register client in My_Whowas structure */
301 Client_RegisterWhowas( c );
303 else if( c->type == CLIENT_SERVER )
305 if( c != This_Server )
307 if( c->conn_id != NONE ) Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt );
308 else Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered: %s", c->id, txt );
311 /* andere Server informieren */
312 if( ! NGIRCd_SignalQuit )
314 if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg );
315 else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :", c->id );
320 if( c->conn_id != NONE )
322 if( c->id[0] ) Log( LOG_NOTICE, "Client \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt );
323 else Log( LOG_NOTICE, "Client unregistered (connection %d): %s", c->conn_id, txt );
325 Log(LOG_WARNING, "Unregistered unknown client \"%s\": %s",
326 c->id[0] ? c->id : "(No Nick)", txt );
334 c = (CLIENT *)c->next;
336 } /* Client_Destroy */
340 Client_DestroyNow( CLIENT *Client )
342 /* Destroy client structure immediately. This function is only
343 * intended for the connection layer to remove client structures
344 * of connections that can't be established! */
348 assert( Client != NULL );
356 /* Wir haben den Client gefunden: entfernen */
357 if( last ) last->next = c->next;
358 else My_Clients = (CLIENT *)c->next;
363 c = (CLIENT *)c->next;
365 } /* Client_DestroyNow */
369 Client_SetHostname( CLIENT *Client, char *Hostname )
371 /* Hostname eines Clients setzen */
373 assert( Client != NULL );
374 assert( Hostname != NULL );
376 strlcpy( Client->host, Hostname, sizeof( Client->host ));
377 } /* Client_SetHostname */
381 Client_SetID( CLIENT *Client, char *ID )
383 /* Hostname eines Clients setzen, Hash-Wert berechnen */
385 assert( Client != NULL );
386 assert( ID != NULL );
388 strlcpy( Client->id, ID, sizeof( Client->id ));
391 Client->hash = Hash( Client->id );
396 Client_SetUser( CLIENT *Client, char *User, bool Idented )
398 /* Username eines Clients setzen */
400 assert( Client != NULL );
401 assert( User != NULL );
403 if( Idented ) strlcpy( Client->user, User, sizeof( Client->user ));
406 Client->user[0] = '~';
407 strlcpy( Client->user + 1, User, sizeof( Client->user ) - 1 );
409 } /* Client_SetUser */
413 Client_SetInfo( CLIENT *Client, char *Info )
415 /* Hostname eines Clients setzen */
417 assert( Client != NULL );
418 assert( Info != NULL );
420 strlcpy( Client->info, Info, sizeof( Client->info ));
421 } /* Client_SetInfo */
425 Client_SetModes( CLIENT *Client, char *Modes )
427 /* Modes eines Clients setzen */
429 assert( Client != NULL );
430 assert( Modes != NULL );
432 strlcpy( Client->modes, Modes, sizeof( Client->modes ));
433 } /* Client_SetModes */
437 Client_SetFlags( CLIENT *Client, char *Flags )
439 /* Flags eines Clients setzen */
441 assert( Client != NULL );
442 assert( Flags != NULL );
444 strlcpy( Client->flags, Flags, sizeof( Client->flags ));
445 } /* Client_SetFlags */
449 Client_SetPassword( CLIENT *Client, char *Pwd )
451 /* Von einem Client geliefertes Passwort */
453 assert( Client != NULL );
454 assert( Pwd != NULL );
456 strlcpy( Client->pwd, Pwd, sizeof( Client->pwd ));
457 } /* Client_SetPassword */
461 Client_SetAway( CLIENT *Client, char *Txt )
463 /* Set AWAY reason of client */
465 assert( Client != NULL );
466 assert( Txt != NULL );
468 strlcpy( Client->away, Txt, sizeof( Client->away ));
469 Log( LOG_DEBUG, "User \"%s\" is away: %s", Client_Mask( Client ), Txt );
470 } /* Client_SetAway */
474 Client_SetType( CLIENT *Client, int Type )
476 assert( Client != NULL );
478 if( Type == CLIENT_SERVER ) Generate_MyToken( Client );
479 Adjust_Counters( Client );
480 } /* Client_SetType */
484 Client_SetHops( CLIENT *Client, int Hops )
486 assert( Client != NULL );
488 } /* Client_SetHops */
492 Client_SetToken( CLIENT *Client, int Token )
494 assert( Client != NULL );
495 Client->token = Token;
496 } /* Client_SetToken */
500 Client_SetIntroducer( CLIENT *Client, CLIENT *Introducer )
502 assert( Client != NULL );
503 assert( Introducer != NULL );
504 Client->introducer = Introducer;
505 } /* Client_SetIntroducer */
509 Client_SetOperByMe( CLIENT *Client, bool OperByMe )
511 assert( Client != NULL );
512 Client->oper_by_me = OperByMe;
513 } /* Client_SetOperByMe */
517 Client_ModeAdd( CLIENT *Client, char Mode )
520 * If Client already alread had Mode, return false.
521 * If the Mode was newly set, return true.
526 assert( Client != NULL );
528 x[0] = Mode; x[1] = '\0';
529 if( ! strchr( Client->modes, x[0] ))
531 /* Client hat den Mode noch nicht -> setzen */
532 strlcat( Client->modes, x, sizeof( Client->modes ));
536 } /* Client_ModeAdd */
540 Client_ModeDel( CLIENT *Client, char Mode )
543 * If Mode was removed, return true.
544 * If Client did not have Mode, return false.
549 assert( Client != NULL );
551 x[0] = Mode; x[1] = '\0';
553 p = strchr( Client->modes, x[0] );
554 if( ! p ) return false;
556 /* Client has Mode -> delete */
563 } /* Client_ModeDel */
567 Client_GetFromConn( CONN_ID Idx )
569 /* return Client-Structure that belongs to the local Connection Idx.
570 * If none is found, return NULL.
580 if( c->conn_id == Idx ) return c;
581 c = (CLIENT *)c->next;
584 } /* Client_GetFromConn */
588 Client_Search( char *Nick )
590 /* return Client-Structure that has the corresponding Nick.
591 * If none is found, return NULL.
594 char search_id[CLIENT_ID_LEN], *ptr;
598 assert( Nick != NULL );
600 /* copy Nick and truncate hostmask if necessary */
601 strlcpy( search_id, Nick, sizeof( search_id ));
602 ptr = strchr( search_id, '!' );
603 if( ptr ) *ptr = '\0';
605 search_hash = Hash( search_id );
610 if( c->hash == search_hash )
612 /* lt. Hash-Wert: Treffer! */
613 if( strcasecmp( c->id, search_id ) == 0 ) return c;
615 c = (CLIENT *)c->next;
618 } /* Client_Search */
622 Client_GetFromToken( CLIENT *Client, int Token )
624 /* Client-Struktur, die den entsprechenden Introducer (=Client)
625 * und das gegebene Token hat, liefern. Wird keine gefunden,
626 * so wird NULL geliefert. */
630 assert( Client != NULL );
636 if(( c->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c->token == Token )) return c;
637 c = (CLIENT *)c->next;
640 } /* Client_GetFromToken */
644 Client_Type( CLIENT *Client )
646 assert( Client != NULL );
652 Client_Conn( CLIENT *Client )
654 assert( Client != NULL );
655 return Client->conn_id;
660 Client_ID( CLIENT *Client )
662 assert( Client != NULL );
665 if( Client->type == CLIENT_USER ) assert( strlen( Client->id ) < CLIENT_NICK_LEN );
668 if( Client->id[0] ) return Client->id;
674 Client_Info( CLIENT *Client )
676 assert( Client != NULL );
682 Client_User( CLIENT *Client )
684 assert( Client != NULL );
685 if( Client->user[0] ) return Client->user;
691 Client_Hostname( CLIENT *Client )
693 assert( Client != NULL );
695 } /* Client_Hostname */
699 Client_Password( CLIENT *Client )
701 assert( Client != NULL );
703 } /* Client_Password */
707 Client_Modes( CLIENT *Client )
709 assert( Client != NULL );
710 return Client->modes;
715 Client_Flags( CLIENT *Client )
717 assert( Client != NULL );
718 return Client->flags;
723 Client_OperByMe( CLIENT *Client )
725 assert( Client != NULL );
726 return Client->oper_by_me;
727 } /* Client_OperByMe */
731 Client_Hops( CLIENT *Client )
733 assert( Client != NULL );
739 Client_Token( CLIENT *Client )
741 assert( Client != NULL );
742 return Client->token;
747 Client_MyToken( CLIENT *Client )
749 assert( Client != NULL );
750 return Client->mytoken;
751 } /* Client_MyToken */
755 Client_NextHop( CLIENT *Client )
759 assert( Client != NULL );
762 while( c->introducer && ( c->introducer != c ) && ( c->introducer != This_Server )) c = c->introducer;
764 } /* Client_NextHop */
768 Client_Mask( CLIENT *Client )
770 /* Client-"ID" liefern, wie sie z.B. fuer
771 * Prefixe benoetigt wird. */
773 assert( Client != NULL );
775 if( Client->type == CLIENT_SERVER ) return Client->id;
777 snprintf( GetID_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user, Client->host );
783 Client_Introducer( CLIENT *Client )
785 assert( Client != NULL );
786 return Client->introducer;
787 } /* Client_Introducer */
791 Client_TopServer( CLIENT *Client )
793 assert( Client != NULL );
794 return Client->topserver;
795 } /* Client_TopServer */
799 Client_HasMode( CLIENT *Client, char Mode )
801 assert( Client != NULL );
802 return strchr( Client->modes, Mode ) != NULL;
803 } /* Client_HasMode */
807 Client_Away( CLIENT *Client )
809 /* AWAY-Text liefern */
811 assert( Client != NULL );
817 Client_CheckNick( CLIENT *Client, char *Nick )
819 /* Nick ueberpruefen */
821 assert( Client != NULL );
822 assert( Nick != NULL );
824 /* Nick ungueltig? */
825 if( ! Client_IsValidNick( Nick ))
827 IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick );
831 /* Nick bereits vergeben? */
832 if( Client_Search( Nick ))
834 /* den Nick gibt es bereits */
835 IRC_WriteStrClient( Client, ERR_NICKNAMEINUSE_MSG, Client_ID( Client ), Nick );
840 } /* Client_CheckNick */
844 Client_CheckID( CLIENT *Client, char *ID )
846 /* Nick ueberpruefen */
848 char str[COMMAND_LEN];
851 assert( Client != NULL );
852 assert( Client->conn_id > NONE );
853 assert( ID != NULL );
856 if( strlen( ID ) > CLIENT_ID_LEN )
858 IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), ID );
862 /* ID bereits vergeben? */
866 if( strcasecmp( c->id, ID ) == 0 )
868 /* die Server-ID gibt es bereits */
869 snprintf( str, sizeof( str ), "ID \"%s\" already registered", ID );
870 if( Client->conn_id != c->conn_id ) Log( LOG_ERR, "%s (on connection %d)!", str, c->conn_id );
871 else Log( LOG_ERR, "%s (via network)!", str );
872 Conn_Close( Client->conn_id, str, str, true);
875 c = (CLIENT *)c->next;
879 } /* Client_CheckID */
885 /* Ersten Client liefern. */
892 Client_Next( CLIENT *c )
894 /* Naechsten Client liefern. Existiert keiner,
895 * so wird NULL geliefert. */
898 return (CLIENT *)c->next;
903 Client_UserCount( void )
905 return Count( CLIENT_USER );
906 } /* Client_UserCount */
910 Client_ServiceCount( void )
912 return Count( CLIENT_SERVICE );;
913 } /* Client_ServiceCount */
917 Client_ServerCount( void )
919 return Count( CLIENT_SERVER );
920 } /* Client_ServerCount */
924 Client_MyUserCount( void )
926 return MyCount( CLIENT_USER );
927 } /* Client_MyUserCount */
931 Client_MyServiceCount( void )
933 return MyCount( CLIENT_SERVICE );
934 } /* Client_MyServiceCount */
938 Client_MyServerCount( void )
947 if(( c->type == CLIENT_SERVER ) && ( c->hops == 1 )) cnt++;
948 c = (CLIENT *)c->next;
951 } /* Client_MyServerCount */
955 Client_OperCount( void )
964 if( c && ( c->type == CLIENT_USER ) && ( strchr( c->modes, 'o' ))) cnt++;
965 c = (CLIENT *)c->next;
968 } /* Client_OperCount */
972 Client_UnknownCount( void )
981 if( c && ( c->type != CLIENT_USER ) && ( c->type != CLIENT_SERVICE ) && ( c->type != CLIENT_SERVER )) cnt++;
982 c = (CLIENT *)c->next;
985 } /* Client_UnknownCount */
989 Client_MaxUserCount( void )
992 } /* Client_MaxUserCount */
996 Client_MyMaxUserCount( void )
999 } /* Client_MyMaxUserCount */
1003 Client_IsValidNick( char *Nick )
1005 /* Ist der Nick gueltig? */
1007 char *ptr, goodchars[20];
1009 assert( Nick != NULL );
1011 strcpy( goodchars, ";0123456789-" );
1013 if( Nick[0] == '#' ) return false;
1014 if( strchr( goodchars, Nick[0] )) return false;
1015 if( strlen( Nick ) >= CLIENT_NICK_LEN ) return false;
1020 if(( *ptr < 'A' ) && ( ! strchr( goodchars, *ptr ))) return false;
1021 if(( *ptr > '}' ) && ( ! strchr( goodchars, *ptr ))) return false;
1026 } /* Client_IsValidNick */
1030 * Return pointer to "My_Whowas" structure.
1033 Client_GetWhowas( void )
1036 } /* Client_GetWhowas */
1039 * Return the index of the last used WHOWAS entry.
1042 Client_GetLastWhowasIndex( void )
1045 } /* Client_GetLastWhowasIndex */
1049 * Get the start time of this client.
1050 * The result is the start time in seconds since 1970-01-01, as reported
1051 * by the C function time(NULL).
1054 Client_StartTime(CLIENT *Client)
1056 assert( Client != NULL );
1057 return Client->starttime;
1058 } /* Client_Uptime */
1062 Count( CLIENT_TYPE Type )
1071 if( c->type == Type ) cnt++;
1072 c = (CLIENT *)c->next;
1079 MyCount( CLIENT_TYPE Type )
1088 if(( c->introducer == This_Server ) && ( c->type == Type )) cnt++;
1089 c = (CLIENT *)c->next;
1096 New_Client_Struct( void )
1098 /* Neue CLIENT-Struktur pre-initialisieren */
1102 c = (CLIENT *)malloc( sizeof( CLIENT ));
1105 Log( LOG_EMERG, "Can't allocate memory! [New_Client_Struct]" );
1109 memset( c, 0, sizeof ( CLIENT ));
1111 c->type = CLIENT_UNKNOWN;
1113 c->oper_by_me = false;
1123 Generate_MyToken( CLIENT *Client )
1132 if( c->mytoken == token )
1134 /* Das Token wurde bereits vergeben */
1139 else c = (CLIENT *)c->next;
1141 Client->mytoken = token;
1142 Log( LOG_DEBUG, "Assigned token %d to server \"%s\".", token, Client->id );
1143 } /* Generate_MyToken */
1147 Adjust_Counters( CLIENT *Client )
1151 assert( Client != NULL );
1153 if( Client->type != CLIENT_USER ) return;
1155 if( Client->conn_id != NONE )
1157 /* Local connection */
1158 count = Client_MyUserCount( );
1159 if( count > My_Max_Users ) My_Max_Users = count;
1161 count = Client_UserCount( );
1162 if( count > Max_Users ) Max_Users = count;
1163 } /* Adjust_Counters */
1167 * Register client in My_Whowas structure for further recall by WHOWAS.
1168 * Note: Only clients that have been connected at least 30 seconds will be
1169 * registered to prevent automated IRC bots to "destroy" a nice server
1173 Client_RegisterWhowas( CLIENT *Client )
1178 assert( Client != NULL );
1181 /* Don't register clients that were connected less than 30 seconds. */
1182 if( now - Client->starttime < 30 )
1185 slot = Last_Whowas + 1;
1186 if( slot >= MAX_WHOWAS || slot < 0 ) slot = 0;
1189 Log( LOG_DEBUG, "Saving WHOWAS information to slot %d ...", slot );
1192 My_Whowas[slot].time = now;
1193 strlcpy( My_Whowas[slot].id, Client_ID( Client ),
1194 sizeof( My_Whowas[slot].id ));
1195 strlcpy( My_Whowas[slot].user, Client_User( Client ),
1196 sizeof( My_Whowas[slot].user ));
1197 strlcpy( My_Whowas[slot].host, Client_Hostname( Client ),
1198 sizeof( My_Whowas[slot].host ));
1199 strlcpy( My_Whowas[slot].info, Client_Info( Client ),
1200 sizeof( My_Whowas[slot].info ));
1201 strlcpy( My_Whowas[slot].server, Client_ID( Client_Introducer( Client )),
1202 sizeof( My_Whowas[slot].server ));
1205 } /* Client_RegisterWhowas */