]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/client.c
Rework cloaked hostname handling, implement "METADATA cloakhost"
[ngircd-alex.git] / src / ngircd / client.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001-2012 Alexander Barton (alex@barton.de)
4  *
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.
10  */
11
12 #define __client_c__
13
14 #include "portab.h"
15
16 /**
17  * @file
18  * Client management.
19  */
20
21 #include "imp.h"
22 #include <assert.h>
23 #include <unistd.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <strings.h>
28 #include <netdb.h>
29
30 #include "defines.h"
31 #include "conn.h"
32
33 #include "exp.h"
34 #include "client.h"
35
36 #include <imp.h>
37 #include "ngircd.h"
38 #include "channel.h"
39 #include "conf.h"
40 #include "conn-func.h"
41 #include "hash.h"
42 #include "irc-write.h"
43 #include "log.h"
44 #include "messages.h"
45
46 #include <exp.h>
47
48 #define GETID_LEN (CLIENT_NICK_LEN-1) + 1 + (CLIENT_USER_LEN-1) + 1 + (CLIENT_HOST_LEN-1) + 1
49
50 static CLIENT *This_Server, *My_Clients;
51
52 static WHOWAS My_Whowas[MAX_WHOWAS];
53 static int Last_Whowas = -1;
54 static long Max_Users, My_Max_Users;
55
56
57 static unsigned long Count PARAMS(( CLIENT_TYPE Type ));
58 static unsigned long MyCount PARAMS(( CLIENT_TYPE Type ));
59
60 static CLIENT *New_Client_Struct PARAMS(( void ));
61 static void Generate_MyToken PARAMS(( CLIENT *Client ));
62 static void Adjust_Counters PARAMS(( CLIENT *Client ));
63
64 static CLIENT *Init_New_Client PARAMS((CONN_ID Idx, CLIENT *Introducer,
65                                        CLIENT *TopServer, int Type, const char *ID,
66                                        const char *User, const char *Hostname, const char *Info,
67                                        int Hops, int Token, const char *Modes,
68                                        bool Idented));
69
70 static void Destroy_UserOrService PARAMS((CLIENT *Client,const char *Txt, const char *FwdMsg,
71                                         bool SendQuit));
72
73 static void cb_introduceClient PARAMS((CLIENT *Client, CLIENT *Prefix,
74                                        void *i));
75
76 GLOBAL void
77 Client_Init( void )
78 {
79         struct hostent *h;
80         
81         This_Server = New_Client_Struct( );
82         if( ! This_Server )
83         {
84                 Log( LOG_EMERG, "Can't allocate client structure for server! Going down." );
85                 Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
86                 exit( 1 );
87         }
88
89         /* Client-Struktur dieses Servers */
90         This_Server->next = NULL;
91         This_Server->type = CLIENT_SERVER;
92         This_Server->conn_id = NONE;
93         This_Server->introducer = This_Server;
94         This_Server->mytoken = 1;
95         This_Server->hops = 0;
96
97         gethostname( This_Server->host, CLIENT_HOST_LEN );
98         if (Conf_DNS) {
99                 h = gethostbyname( This_Server->host );
100                 if (h) strlcpy(This_Server->host, h->h_name, sizeof(This_Server->host));
101         }
102         Client_SetID( This_Server, Conf_ServerName );
103         Client_SetInfo( This_Server, Conf_ServerInfo );
104
105         My_Clients = This_Server;
106         
107         memset( &My_Whowas, 0, sizeof( My_Whowas ));
108 } /* Client_Init */
109
110
111 GLOBAL void
112 Client_Exit( void )
113 {
114         CLIENT *c, *next;
115         int cnt;
116
117         if( NGIRCd_SignalRestart ) Client_Destroy( This_Server, "Server going down (restarting).", NULL, false );
118         else Client_Destroy( This_Server, "Server going down.", NULL, false );
119         
120         cnt = 0;
121         c = My_Clients;
122         while( c )
123         {
124                 cnt++;
125                 next = (CLIENT *)c->next;
126                 free( c );
127                 c = next;
128         }
129         if( cnt ) Log( LOG_INFO, "Freed %d client structure%s.", cnt, cnt == 1 ? "" : "s" );
130 } /* Client_Exit */
131
132
133 GLOBAL CLIENT *
134 Client_ThisServer( void )
135 {
136         return This_Server;
137 } /* Client_ThisServer */
138
139
140 /**
141  * Initialize new local client; wrapper function for Init_New_Client().
142  * @return New CLIENT structure.
143  */
144 GLOBAL CLIENT *
145 Client_NewLocal(CONN_ID Idx, const char *Hostname, int Type, bool Idented)
146 {
147         return Init_New_Client(Idx, This_Server, NULL, Type, NULL, NULL,
148                 Hostname, NULL, 0, 0, NULL, Idented);
149 } /* Client_NewLocal */
150
151
152 /**
153  * Initialize new remote server; wrapper function for Init_New_Client().
154  * @return New CLIENT structure.
155  */
156 GLOBAL CLIENT *
157 Client_NewRemoteServer(CLIENT *Introducer, const char *Hostname, CLIENT *TopServer,
158  int Hops, int Token, const char *Info, bool Idented)
159 {
160         return Init_New_Client(NONE, Introducer, TopServer, CLIENT_SERVER,
161                 Hostname, NULL, Hostname, Info, Hops, Token, NULL, Idented);
162 } /* Client_NewRemoteServer */
163
164
165 /**
166  * Initialize new remote client; wrapper function for Init_New_Client().
167  * @return New CLIENT structure.
168  */
169 GLOBAL CLIENT *
170 Client_NewRemoteUser(CLIENT *Introducer, const char *Nick, int Hops, const char *User,
171  const char *Hostname, int Token, const char *Modes, const char *Info, bool Idented)
172 {
173         return Init_New_Client(NONE, Introducer, NULL, CLIENT_USER, Nick,
174                 User, Hostname, Info, Hops, Token, Modes, Idented);
175 } /* Client_NewRemoteUser */
176
177
178 /**
179  * Initialize new client and set up the given parameters like client type,
180  * user name, host name, introducing server etc. ...
181  * @return New CLIENT structure.
182  */
183 static CLIENT *
184 Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer,
185   int Type, const char *ID, const char *User, const char *Hostname,
186   const char *Info, int Hops, int Token, const char *Modes, bool Idented)
187 {
188         CLIENT *client;
189
190         assert(Idx >= NONE);
191         assert(Introducer != NULL);
192
193         client = New_Client_Struct();
194         if (!client)
195                 return NULL;
196
197         client->starttime = time(NULL);
198         client->conn_id = Idx;
199         client->introducer = Introducer;
200         client->topserver = TopServer;
201         client->type = Type;
202         if (ID)
203                 Client_SetID(client, ID);
204         if (User) {
205                 Client_SetUser(client, User, Idented);
206                 Client_SetOrigUser(client, User);
207         }
208         if (Hostname)
209                 Client_SetHostname(client, Hostname);
210         if (Info)
211                 Client_SetInfo(client, Info);
212         client->hops = Hops;
213         client->token = Token;
214         if (Modes)
215                 Client_SetModes(client, Modes);
216         if (Type == CLIENT_SERVER)
217                 Generate_MyToken(client);
218
219         if (strchr(client->modes, 'a'))
220                 strlcpy(client->away, DEFAULT_AWAY_MSG, sizeof(client->away));
221
222         client->next = (POINTER *)My_Clients;
223         My_Clients = client;
224
225         Adjust_Counters(client);
226
227         return client;
228 } /* Init_New_Client */
229
230
231 GLOBAL void
232 Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool SendQuit )
233 {
234         /* remove a client */
235         
236         CLIENT *last, *c;
237         char msg[LINE_LEN];
238         const char *txt;
239
240         assert( Client != NULL );
241
242         if( LogMsg ) txt = LogMsg;
243         else txt = FwdMsg;
244         if( ! txt ) txt = "Reason unknown.";
245
246         /* netsplit message */
247         if( Client->type == CLIENT_SERVER ) {
248                 strlcpy(msg, This_Server->id, sizeof (msg));
249                 strlcat(msg, " ", sizeof (msg));
250                 strlcat(msg, Client->id, sizeof (msg));
251         }
252
253         last = NULL;
254         c = My_Clients;
255         while( c )
256         {
257                 if(( Client->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c != Client ))
258                 {
259                         /*
260                          * The client that is about to be removed is a server,
261                          * the client we are checking right now is a child of that
262                          * server and thus has to be removed, too.
263                          *
264                          * Call Client_Destroy() recursively with the server as the
265                          * new "object to be removed". This starts the cycle again, until
266                          * all servers that are linked via the original server have been
267                          * removed.
268                          */
269                         Client_Destroy( c, NULL, msg, false );
270                         last = NULL;
271                         c = My_Clients;
272                         continue;
273                 }
274                 if( c == Client )
275                 {
276                         /* found  the client: remove it */
277                         if( last ) last->next = c->next;
278                         else My_Clients = (CLIENT *)c->next;
279
280                         if(c->type == CLIENT_USER || c->type == CLIENT_SERVICE)
281                                 Destroy_UserOrService(c, txt, FwdMsg, SendQuit);
282                         else if( c->type == CLIENT_SERVER )
283                         {
284                                 if( c != This_Server )
285                                 {
286                                         if( c->conn_id != NONE ) Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt );
287                                         else Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered: %s", c->id, txt );
288                                 }
289
290                                 /* inform other servers */
291                                 if( ! NGIRCd_SignalQuit )
292                                 {
293                                         if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg );
294                                         else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :", c->id );
295                                 }
296                         }
297                         else
298                         {
299                                 if( c->conn_id != NONE )
300                                 {
301                                         if( c->id[0] ) Log( LOG_NOTICE, "Client \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt );
302                                         else Log( LOG_NOTICE, "Client unregistered (connection %d): %s", c->conn_id, txt );
303                                 } else {
304                                         Log(LOG_WARNING, "Unregistered unknown client \"%s\": %s",
305                                                                 c->id[0] ? c->id : "(No Nick)", txt );
306                                 }
307                         }
308
309                         free( c );
310                         break;
311                 }
312                 last = c;
313                 c = (CLIENT *)c->next;
314         }
315 } /* Client_Destroy */
316
317
318 /**
319  * Set client hostname.
320  *
321  * If global hostname cloaking is in effect, don't set the real hostname
322  * but the configured one.
323  *
324  * @param Client The client of which the hostname should be set.
325  * @param Hostname The new hostname.
326  */
327 GLOBAL void
328 Client_SetHostname( CLIENT *Client, const char *Hostname )
329 {
330         assert(Client != NULL);
331         assert(Hostname != NULL);
332
333         if (strlen(Conf_CloakHost)) {
334                 char cloak[GETID_LEN];
335
336                 strlcpy(cloak, Hostname, GETID_LEN);
337                 strlcat(cloak, Conf_CloakHostSalt, GETID_LEN);
338                 snprintf(cloak, GETID_LEN, Conf_CloakHost, Hash(cloak));
339
340                 LogDebug("Updating hostname of \"%s\": \"%s\" -> \"%s\"",
341                         Client_ID(Client), Client->host, cloak);
342                 strlcpy(Client->host, cloak, sizeof(Client->host));
343         } else {
344                 LogDebug("Updating hostname of \"%s\": \"%s\" -> \"%s\"",
345                          Client_ID(Client), Client->host, Hostname);
346                 strlcpy(Client->host, Hostname, sizeof(Client->host));
347         }
348 } /* Client_SetHostname */
349
350
351 GLOBAL void
352 Client_SetID( CLIENT *Client, const char *ID )
353 {
354         assert( Client != NULL );
355         assert( ID != NULL );
356         
357         strlcpy( Client->id, ID, sizeof( Client->id ));
358
359         if (Conf_CloakUserToNick) {
360                 strlcpy( Client->user, ID, sizeof( Client->user ));
361                 strlcpy( Client->info, ID, sizeof( Client->info ));
362         }
363
364         /* Hash */
365         Client->hash = Hash( Client->id );
366 } /* Client_SetID */
367
368
369 GLOBAL void
370 Client_SetUser( CLIENT *Client, const char *User, bool Idented )
371 {
372         /* set clients username */
373
374         assert( Client != NULL );
375         assert( User != NULL );
376
377         if (Conf_CloakUserToNick) {
378                 strlcpy(Client->user, Client->id, sizeof(Client->user));
379         } else if (Idented) {
380                 strlcpy(Client->user, User, sizeof(Client->user));
381         } else {
382                 Client->user[0] = '~';
383                 strlcpy(Client->user + 1, User, sizeof(Client->user) - 1);
384         }
385 } /* Client_SetUser */
386
387
388 /**
389  * Set "original" user name of a client.
390  * This function saves the "original" user name, the user name specified by
391  * the peer using the USER command, into the CLIENT structure. This user
392  * name may be used for authentication, for example.
393  * @param Client The client.
394  * @param User User name to set.
395  */
396 GLOBAL void
397 Client_SetOrigUser(CLIENT UNUSED *Client, const char UNUSED *User)
398 {
399         assert(Client != NULL);
400         assert(User != NULL);
401
402 #if defined(PAM) && defined(IDENTAUTH)
403         strlcpy(Client->orig_user, User, sizeof(Client->orig_user));
404 #endif
405 } /* Client_SetOrigUser */
406
407
408 GLOBAL void
409 Client_SetInfo( CLIENT *Client, const char *Info )
410 {
411         /* set client hostname */
412
413         assert( Client != NULL );
414         assert( Info != NULL );
415
416         if (Conf_CloakUserToNick)
417                 strlcpy(Client->info, Client->id, sizeof(Client->info));
418         else
419                 strlcpy(Client->info, Info, sizeof(Client->info));
420 } /* Client_SetInfo */
421
422
423 GLOBAL void
424 Client_SetModes( CLIENT *Client, const char *Modes )
425 {
426         assert( Client != NULL );
427         assert( Modes != NULL );
428
429         strlcpy(Client->modes, Modes, sizeof( Client->modes ));
430 } /* Client_SetModes */
431
432
433 GLOBAL void
434 Client_SetFlags( CLIENT *Client, const char *Flags )
435 {
436         assert( Client != NULL );
437         assert( Flags != NULL );
438
439         strlcpy(Client->flags, Flags, sizeof(Client->flags));
440 } /* Client_SetFlags */
441
442
443 GLOBAL void
444 Client_SetAway( CLIENT *Client, const char *Txt )
445 {
446         /* Set AWAY reason of client */
447
448         assert( Client != NULL );
449         assert( Txt != NULL );
450
451         strlcpy( Client->away, Txt, sizeof( Client->away ));
452         LogDebug("%s \"%s\" is away: %s", Client_TypeText(Client),
453                  Client_Mask(Client), Txt);
454 } /* Client_SetAway */
455
456
457 GLOBAL void
458 Client_SetType( CLIENT *Client, int Type )
459 {
460         assert( Client != NULL );
461         Client->type = Type;
462         if( Type == CLIENT_SERVER ) Generate_MyToken( Client );
463         Adjust_Counters( Client );
464 } /* Client_SetType */
465
466
467 GLOBAL void
468 Client_SetHops( CLIENT *Client, int Hops )
469 {
470         assert( Client != NULL );
471         Client->hops = Hops;
472 } /* Client_SetHops */
473
474
475 GLOBAL void
476 Client_SetToken( CLIENT *Client, int Token )
477 {
478         assert( Client != NULL );
479         Client->token = Token;
480 } /* Client_SetToken */
481
482
483 GLOBAL void
484 Client_SetIntroducer( CLIENT *Client, CLIENT *Introducer )
485 {
486         assert( Client != NULL );
487         assert( Introducer != NULL );
488         Client->introducer = Introducer;
489 } /* Client_SetIntroducer */
490
491
492 GLOBAL void
493 Client_SetOperByMe( CLIENT *Client, bool OperByMe )
494 {
495         assert( Client != NULL );
496         Client->oper_by_me = OperByMe;
497 } /* Client_SetOperByMe */
498
499
500 GLOBAL bool
501 Client_ModeAdd( CLIENT *Client, char Mode )
502 {
503         /* Set Mode.
504          * If Client already alread had Mode, return false.
505          * If the Mode was newly set, return true.
506          */
507
508         char x[2];
509
510         assert( Client != NULL );
511
512         x[0] = Mode; x[1] = '\0';
513         if (!strchr( Client->modes, x[0])) {
514                 strlcat( Client->modes, x, sizeof( Client->modes ));
515                 return true;
516         }
517         else return false;
518 } /* Client_ModeAdd */
519
520
521 GLOBAL bool
522 Client_ModeDel( CLIENT *Client, char Mode )
523 {
524         /* Delete Mode.
525          * If Mode was removed, return true.
526          * If Client did not have Mode, return false.
527          */
528
529         char x[2], *p;
530
531         assert( Client != NULL );
532
533         x[0] = Mode; x[1] = '\0';
534
535         p = strchr( Client->modes, x[0] );
536         if( ! p ) return false;
537
538         /* Client has Mode -> delete */
539         while( *p )
540         {
541                 *p = *(p + 1);
542                 p++;
543         }
544         return true;
545 } /* Client_ModeDel */
546
547
548 GLOBAL CLIENT *
549 Client_Search( const char *Nick )
550 {
551         /* return Client-Structure that has the corresponding Nick.
552          * If none is found, return NULL.
553          */
554
555         char search_id[CLIENT_ID_LEN], *ptr;
556         CLIENT *c = NULL;
557         UINT32 search_hash;
558
559         assert( Nick != NULL );
560
561         /* copy Nick and truncate hostmask if necessary */
562         strlcpy( search_id, Nick, sizeof( search_id ));
563         ptr = strchr( search_id, '!' );
564         if( ptr ) *ptr = '\0';
565
566         search_hash = Hash(search_id);
567
568         c = My_Clients;
569         while (c) {
570                 if (c->hash == search_hash && strcasecmp(c->id, search_id) == 0)
571                         return c;
572                 c = (CLIENT *)c->next;
573         }
574         return NULL;
575 } /* Client_Search */
576
577
578 /**
579  * Get client structure ("introducer") identfied by a server token.
580  * @return CLIENT structure or NULL if none could be found.
581  */
582 GLOBAL CLIENT *
583 Client_GetFromToken( CLIENT *Client, int Token )
584 {
585         CLIENT *c;
586
587         assert( Client != NULL );
588
589         if (!Token)
590                 return NULL;
591
592         c = My_Clients;
593         while (c) {
594                 if ((c->type == CLIENT_SERVER) && (c->introducer == Client) &&
595                         (c->token == Token))
596                                 return c;
597                 c = (CLIENT *)c->next;
598         }
599         return NULL;
600 } /* Client_GetFromToken */
601
602
603 GLOBAL int
604 Client_Type( CLIENT *Client )
605 {
606         assert( Client != NULL );
607         return Client->type;
608 } /* Client_Type */
609
610
611 GLOBAL CONN_ID
612 Client_Conn( CLIENT *Client )
613 {
614         assert( Client != NULL );
615         return Client->conn_id;
616 } /* Client_Conn */
617
618
619 GLOBAL char *
620 Client_ID( CLIENT *Client )
621 {
622         assert( Client != NULL );
623
624 #ifdef DEBUG
625         if(Client->type == CLIENT_USER)
626                 assert(strlen(Client->id) < Conf_MaxNickLength);
627 #endif
628                                                    
629         if( Client->id[0] ) return Client->id;
630         else return "*";
631 } /* Client_ID */
632
633
634 GLOBAL char *
635 Client_Info( CLIENT *Client )
636 {
637         assert( Client != NULL );
638         return Client->info;
639 } /* Client_Info */
640
641
642 GLOBAL char *
643 Client_User( CLIENT *Client )
644 {
645         assert( Client != NULL );
646         return Client->user[0] ? Client->user : "~";
647 } /* Client_User */
648
649
650 #ifdef PAM
651
652 /**
653  * Get the "original" user name as supplied by the USER command.
654  * The user name as given by the client is used for authentication instead
655  * of the one detected using IDENT requests.
656  * @param Client The client.
657  * @return Original user name.
658  */
659 GLOBAL char *
660 Client_OrigUser(CLIENT *Client) {
661 #ifndef IDENTAUTH
662         char *user = Client->user;
663
664         if (user[0] == '~')
665                 user++;
666         return user;
667 #else
668         return Client->orig_user;
669 #endif
670 } /* Client_OrigUser */
671
672 #endif
673
674 /**
675  * Return the hostname of a client.
676  * @param Client Pointer to client structure
677  * @return Pointer to client hostname
678  */
679 GLOBAL char *
680 Client_Hostname(CLIENT *Client)
681 {
682         assert (Client != NULL);
683         return Client->host;
684 }
685
686 /**
687  * Return the cloaked hostname of a client, if set.
688  * @param Client Pointer to the client structure.
689  * @return Pointer to the cloaked hostname or NULL if not set.
690  */
691 GLOBAL char *
692 Client_HostnameCloaked(CLIENT *Client)
693 {
694         assert(Client != NULL);
695         return Client->cloaked;
696 }
697
698 /**
699  * Get (potentially cloaked) hostname of a client to display it to other users.
700  *
701  * If the client has not enabled cloaking, the real hostname is used.
702  * Please note that this function uses a global static buffer, so you can't
703  * nest invocations without overwriting earlier results!
704  *
705  * @param Client Pointer to client structure
706  * @return Pointer to client hostname
707  */
708 GLOBAL char *
709 Client_HostnameDisplayed(CLIENT *Client)
710 {
711         assert(Client != NULL);
712
713         /* Client isn't cloaked at all, return real hostname: */
714         if (!Client_HasMode(Client, 'x'))
715                 return Client_Hostname(Client);
716
717         /* Use an already saved cloaked hostname, if there is one */
718         if (Client->cloaked[0])
719                 return Client->cloaked;
720
721         Client_UpdateCloakedHostname(Client, NULL, NULL);
722         return Client->cloaked;
723 }
724
725 /**
726  * Update (and generate, if necessary) the cloaked hostname of a client.
727  *
728  * The newly set cloaked hostname is announced in the network using METADATA
729  * commands to peers that support this feature.
730  *
731  * @param Client The client of which the cloaked hostname should be updated.
732  * @param Origin The originator of the hostname change, or NULL if this server.
733  * @param Hostname The new cloaked hostname, or NULL if it should be generated.
734  */
735 GLOBAL void
736 Client_UpdateCloakedHostname(CLIENT *Client, CLIENT *Origin,
737                              const char *Hostname)
738 {
739         static char Cloak_Buffer[CLIENT_HOST_LEN];
740
741         assert(Client != NULL);
742         if (!Origin)
743                 Origin = Client_ThisServer();
744
745         if (!Hostname) {
746                 /* Generate new cloaked hostname */
747                 if (*Conf_CloakHostModeX) {
748                         strlcpy(Cloak_Buffer, Client->host, CLIENT_HOST_LEN);
749                         strlcat(Cloak_Buffer, Conf_CloakHostSalt,
750                                 CLIENT_HOST_LEN);
751                         snprintf(Client->cloaked, sizeof(Client->cloaked),
752                                  Conf_CloakHostModeX, Hash(Cloak_Buffer));
753                 } else
754                         strlcpy(Client->cloaked, Client_ID(Client->introducer),
755                                 sizeof(Client->cloaked));
756         } else
757                 strlcpy(Client->cloaked, Hostname, sizeof(Client->cloaked));
758         LogDebug("Cloaked hostname of \"%s\" updated to \"%s\"",
759                  Client_ID(Client), Client->cloaked);
760
761         /* Inform other servers in the network */
762         IRC_WriteStrServersPrefixFlag(Client_NextHop(Origin), Origin, 'M',
763                                       "METADATA %s cloakhost :%s",
764                                       Client_ID(Client), Client->cloaked);
765 }
766
767 GLOBAL char *
768 Client_Modes( CLIENT *Client )
769 {
770         assert( Client != NULL );
771         return Client->modes;
772 } /* Client_Modes */
773
774
775 GLOBAL char *
776 Client_Flags( CLIENT *Client )
777 {
778         assert( Client != NULL );
779         return Client->flags;
780 } /* Client_Flags */
781
782
783 GLOBAL bool
784 Client_OperByMe( CLIENT *Client )
785 {
786         assert( Client != NULL );
787         return Client->oper_by_me;
788 } /* Client_OperByMe */
789
790
791 GLOBAL int
792 Client_Hops( CLIENT *Client )
793 {
794         assert( Client != NULL );
795         return Client->hops;
796 } /* Client_Hops */
797
798
799 GLOBAL int
800 Client_Token( CLIENT *Client )
801 {
802         assert( Client != NULL );
803         return Client->token;
804 } /* Client_Token */
805
806
807 GLOBAL int
808 Client_MyToken( CLIENT *Client )
809 {
810         assert( Client != NULL );
811         return Client->mytoken;
812 } /* Client_MyToken */
813
814
815 GLOBAL CLIENT *
816 Client_NextHop( CLIENT *Client )
817 {
818         CLIENT *c;
819
820         assert( Client != NULL );
821
822         c = Client;
823         while( c->introducer && ( c->introducer != c ) && ( c->introducer != This_Server ))
824                 c = c->introducer;
825
826         return c;
827 } /* Client_NextHop */
828
829
830 /**
831  * Return ID of a client: "client!user@host"
832  * This client ID is used for IRC prefixes, for example.
833  * Please note that this function uses a global static buffer, so you can't
834  * nest invocations without overwriting earlier results!
835  * @param Client Pointer to client structure
836  * @return Pointer to global buffer containing the client ID
837  */
838 GLOBAL char *
839 Client_Mask( CLIENT *Client )
840 {
841         static char Mask_Buffer[GETID_LEN];
842
843         assert (Client != NULL);
844
845         /* Servers: return name only, there is no "mask" */
846         if (Client->type == CLIENT_SERVER)
847                 return Client->id;
848
849         snprintf(Mask_Buffer, GETID_LEN, "%s!%s@%s",
850                  Client->id, Client->user, Client->host);
851         return Mask_Buffer;
852 } /* Client_Mask */
853
854
855 /**
856  * Return ID of a client with cloaked hostname: "client!user@server-name"
857  *
858  * This client ID is used for IRC prefixes, for example.
859  * Please note that this function uses a global static buffer, so you can't
860  * nest invocations without overwriting earlier results!
861  * If the client has not enabled cloaking, the real hostname is used.
862  *
863  * @param Client Pointer to client structure
864  * @return Pointer to global buffer containing the client ID
865  */
866 GLOBAL char *
867 Client_MaskCloaked(CLIENT *Client)
868 {
869         static char Mask_Buffer[GETID_LEN];
870
871         assert (Client != NULL);
872
873         /* Is the client using cloaking at all? */
874         if (!Client_HasMode(Client, 'x'))
875                 return Client_Mask(Client);
876
877         snprintf(Mask_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user,
878                  Client_HostnameDisplayed(Client));
879
880         return Mask_Buffer;
881 } /* Client_MaskCloaked */
882
883
884 GLOBAL CLIENT *
885 Client_Introducer( CLIENT *Client )
886 {
887         assert( Client != NULL );
888         return Client->introducer;
889 } /* Client_Introducer */
890
891
892 GLOBAL CLIENT *
893 Client_TopServer( CLIENT *Client )
894 {
895         assert( Client != NULL );
896         return Client->topserver;
897 } /* Client_TopServer */
898
899
900 GLOBAL bool
901 Client_HasMode( CLIENT *Client, char Mode )
902 {
903         assert( Client != NULL );
904         return strchr( Client->modes, Mode ) != NULL;
905 } /* Client_HasMode */
906
907
908 GLOBAL char *
909 Client_Away( CLIENT *Client )
910 {
911         assert( Client != NULL );
912         return Client->away;
913 } /* Client_Away */
914
915
916 /**
917  * Make sure that a given nickname is valid.
918  *
919  * If the nickname is not valid for the given client, this function sends back
920  * the appropriate error messages.
921  *
922  * @param       Client Client that wants to change the nickname.
923  * @param       Nick New nickname.
924  * @returns     true if nickname is valid, false otherwise.
925  */
926 GLOBAL bool
927 Client_CheckNick(CLIENT *Client, char *Nick)
928 {
929         assert(Client != NULL);
930         assert(Nick != NULL);
931
932         if (!Client_IsValidNick(Nick)) {
933                 if (strlen(Nick ) >= Conf_MaxNickLength)
934                         IRC_WriteStrClient(Client, ERR_NICKNAMETOOLONG_MSG,
935                                            Client_ID(Client), Nick,
936                                            Conf_MaxNickLength - 1);
937                 else
938                         IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
939                                            Client_ID(Client), Nick);
940                 return false;
941         }
942
943         if (Client_Type(Client) != CLIENT_SERVER
944             && Client_Type(Client) != CLIENT_SERVICE) {
945                 /* Make sure that this isn't a restricted/forbidden nickname */
946                 if (Conf_NickIsBlocked(Nick)) {
947                         IRC_WriteStrClient(Client, ERR_FORBIDDENNICKNAME_MSG,
948                                            Client_ID(Client), Nick);
949                         return false;
950                 }
951         }
952
953         /* Nickname already registered? */
954         if (Client_Search(Nick)) {
955                 IRC_WriteStrClient(Client, ERR_NICKNAMEINUSE_MSG,
956                         Client_ID(Client), Nick);
957                 return false;
958         }
959
960         return true;
961 } /* Client_CheckNick */
962
963
964 GLOBAL bool
965 Client_CheckID( CLIENT *Client, char *ID )
966 {
967         char str[COMMAND_LEN];
968         CLIENT *c;
969
970         assert( Client != NULL );
971         assert( Client->conn_id > NONE );
972         assert( ID != NULL );
973
974         /* ID too long? */
975         if (strlen(ID) > CLIENT_ID_LEN) {
976                 IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID(Client), ID);
977                 return false;
978         }
979
980         /* ID already in use? */
981         c = My_Clients;
982         while (c) {
983                 if (strcasecmp(c->id, ID) == 0) {
984                         snprintf(str, sizeof(str), "ID \"%s\" already registered", ID);
985                         if (c->conn_id != NONE)
986                                 Log(LOG_ERR, "%s (on connection %d)!", str, c->conn_id);
987                         else
988                                 Log(LOG_ERR, "%s (via network)!", str);
989                         Conn_Close(Client->conn_id, str, str, true);
990                         return false;
991                 }
992                 c = (CLIENT *)c->next;
993         }
994
995         return true;
996 } /* Client_CheckID */
997
998
999 GLOBAL CLIENT *
1000 Client_First( void )
1001 {
1002         return My_Clients;
1003 } /* Client_First */
1004
1005
1006 GLOBAL CLIENT *
1007 Client_Next( CLIENT *c )
1008 {
1009         assert( c != NULL );
1010         return (CLIENT *)c->next;
1011 } /* Client_Next */
1012
1013
1014 GLOBAL long
1015 Client_UserCount( void )
1016 {
1017         return Count( CLIENT_USER );
1018 } /* Client_UserCount */
1019
1020
1021 GLOBAL long
1022 Client_ServiceCount( void )
1023 {
1024         return Count( CLIENT_SERVICE );;
1025 } /* Client_ServiceCount */
1026
1027
1028 GLOBAL long
1029 Client_ServerCount( void )
1030 {
1031         return Count( CLIENT_SERVER );
1032 } /* Client_ServerCount */
1033
1034
1035 GLOBAL long
1036 Client_MyUserCount( void )
1037 {
1038         return MyCount( CLIENT_USER );
1039 } /* Client_MyUserCount */
1040
1041
1042 GLOBAL long
1043 Client_MyServiceCount( void )
1044 {
1045         return MyCount( CLIENT_SERVICE );
1046 } /* Client_MyServiceCount */
1047
1048
1049 GLOBAL unsigned long
1050 Client_MyServerCount( void )
1051 {
1052         CLIENT *c;
1053         unsigned long cnt = 0;
1054
1055         c = My_Clients;
1056         while( c )
1057         {
1058                 if(( c->type == CLIENT_SERVER ) && ( c->hops == 1 )) cnt++;
1059                 c = (CLIENT *)c->next;
1060         }
1061         return cnt;
1062 } /* Client_MyServerCount */
1063
1064
1065 GLOBAL unsigned long
1066 Client_OperCount( void )
1067 {
1068         CLIENT *c;
1069         unsigned long cnt = 0;
1070
1071         c = My_Clients;
1072         while( c )
1073         {
1074                 if( c && ( c->type == CLIENT_USER ) && ( strchr( c->modes, 'o' ))) cnt++;
1075                 c = (CLIENT *)c->next;
1076         }
1077         return cnt;
1078 } /* Client_OperCount */
1079
1080
1081 GLOBAL unsigned long
1082 Client_UnknownCount( void )
1083 {
1084         CLIENT *c;
1085         unsigned long cnt = 0;
1086
1087         c = My_Clients;
1088         while( c )
1089         {
1090                 if( c && ( c->type != CLIENT_USER ) && ( c->type != CLIENT_SERVICE ) && ( c->type != CLIENT_SERVER )) cnt++;
1091                 c = (CLIENT *)c->next;
1092         }
1093
1094         return cnt;
1095 } /* Client_UnknownCount */
1096
1097
1098 GLOBAL long
1099 Client_MaxUserCount( void )
1100 {
1101         return Max_Users;
1102 } /* Client_MaxUserCount */
1103
1104
1105 GLOBAL long
1106 Client_MyMaxUserCount( void )
1107 {
1108         return My_Max_Users;
1109 } /* Client_MyMaxUserCount */
1110
1111
1112 /**
1113  * Check that a given nickname is valid.
1114  *
1115  * @param       Nick the nickname to check.
1116  * @returns     true if nickname is valid, false otherwise.
1117  */
1118 GLOBAL bool
1119 Client_IsValidNick(const char *Nick)
1120 {
1121         const char *ptr;
1122         static const char goodchars[] = ";0123456789-";
1123
1124         assert (Nick != NULL);
1125
1126         if (strchr(goodchars, Nick[0]))
1127                 return false;
1128         if (strlen(Nick ) >= Conf_MaxNickLength)
1129                 return false;
1130
1131         ptr = Nick;
1132         while (*ptr) {
1133                 if (*ptr < 'A' && !strchr(goodchars, *ptr ))
1134                         return false;
1135                 if (*ptr > '}')
1136                         return false;
1137                 ptr++;
1138         }
1139
1140         return true;
1141 } /* Client_IsValidNick */
1142
1143
1144 /**
1145  * Return pointer to "My_Whowas" structure.
1146  */
1147 GLOBAL WHOWAS *
1148 Client_GetWhowas( void )
1149 {
1150         return My_Whowas;
1151 } /* Client_GetWhowas */
1152
1153 /**
1154  * Return the index of the last used WHOWAS entry.
1155  */
1156 GLOBAL int
1157 Client_GetLastWhowasIndex( void )
1158 {
1159         return Last_Whowas;
1160 } /* Client_GetLastWhowasIndex */
1161
1162
1163 /**
1164  * Get the start time of this client.
1165  * The result is the start time in seconds since 1970-01-01, as reported
1166  * by the C function time(NULL).
1167  */
1168 GLOBAL time_t
1169 Client_StartTime(CLIENT *Client)
1170 {
1171         assert( Client != NULL );
1172         return Client->starttime;
1173 } /* Client_Uptime */
1174
1175
1176 /**
1177  * Reject a client when logging in.
1178  *
1179  * This function is called when a client isn't allowed to connect to this
1180  * server. Possible reasons are bad server password, bad PAM password,
1181  * or that the client is G/K-Line'd.
1182  *
1183  * After calling this function, the client isn't connected any more.
1184  *
1185  * @param Client The client to reject.
1186  * @param Reason The reason why the client has been rejected.
1187  * @param InformClient If true, send the exact reason to the client.
1188  */
1189 GLOBAL void
1190 Client_Reject(CLIENT *Client, const char *Reason, bool InformClient)
1191 {
1192         char info[COMMAND_LEN];
1193
1194         assert(Client != NULL);
1195         assert(Reason != NULL);
1196
1197         if (InformClient)
1198                 snprintf(info, sizeof(info), "Access denied: %s", Reason);
1199         else
1200                 strcpy(info, "Access denied: Bad password?");
1201
1202         Log(LOG_ERR,
1203             "User \"%s\" rejected (connection %d): %s!",
1204             Client_Mask(Client), Client_Conn(Client), Reason);
1205         Conn_Close(Client_Conn(Client), Reason, info, true);
1206 }
1207
1208
1209 /**
1210  * Introduce a new user or service client in the network.
1211  *
1212  * @param From Remote server introducing the client or NULL (local).
1213  * @param Client New client.
1214  * @param Type Type of the client (CLIENT_USER or CLIENT_SERVICE).
1215  */
1216 GLOBAL void
1217 Client_Introduce(CLIENT *From, CLIENT *Client, int Type)
1218 {
1219         /* Set client type (user or service) */
1220         Client_SetType(Client, Type);
1221
1222         if (From) {
1223                 if (Conf_NickIsService(Conf_GetServer(Client_Conn(From)),
1224                                    Client_ID(Client)))
1225                         Client_SetType(Client, CLIENT_SERVICE);
1226                 LogDebug("%s \"%s\" (+%s) registered (via %s, on %s, %d hop%s).",
1227                          Client_TypeText(Client), Client_Mask(Client),
1228                          Client_Modes(Client), Client_ID(From),
1229                          Client_ID(Client_Introducer(Client)),
1230                          Client_Hops(Client), Client_Hops(Client) > 1 ? "s": "");
1231         } else {
1232                 Log(LOG_NOTICE, "%s \"%s\" registered (connection %d).",
1233                     Client_TypeText(Client), Client_Mask(Client),
1234                     Client_Conn(Client));
1235                 Log_ServerNotice('c', "Client connecting: %s (%s@%s) [%s] - %s",
1236                                  Client_ID(Client), Client_User(Client),
1237                                  Client_Hostname(Client),
1238                                  Conn_IPA(Client_Conn(Client)),
1239                                  Client_TypeText(Client));
1240         }
1241
1242         /* Inform other servers */
1243         IRC_WriteStrServersPrefixFlag_CB(From,
1244                                 From != NULL ? From : Client_ThisServer(),
1245                                 '\0', cb_introduceClient, (void *)Client);
1246 } /* Client_Introduce */
1247
1248
1249 static unsigned long
1250 Count( CLIENT_TYPE Type )
1251 {
1252         CLIENT *c;
1253         unsigned long cnt = 0;
1254
1255         c = My_Clients;
1256         while( c )
1257         {
1258                 if( c->type == Type ) cnt++;
1259                 c = (CLIENT *)c->next;
1260         }
1261         return cnt;
1262 } /* Count */
1263
1264
1265 static unsigned long
1266 MyCount( CLIENT_TYPE Type )
1267 {
1268         CLIENT *c;
1269         unsigned long cnt = 0;
1270
1271         c = My_Clients;
1272         while( c )
1273         {
1274                 if(( c->introducer == This_Server ) && ( c->type == Type )) cnt++;
1275                 c = (CLIENT *)c->next;
1276         }
1277         return cnt;
1278 } /* MyCount */
1279
1280
1281 static CLIENT *
1282 New_Client_Struct( void )
1283 {
1284         /* Neue CLIENT-Struktur pre-initialisieren */
1285
1286         CLIENT *c;
1287
1288         c = (CLIENT *)malloc( sizeof( CLIENT ));
1289         if( ! c )
1290         {
1291                 Log( LOG_EMERG, "Can't allocate memory! [New_Client_Struct]" );
1292                 return NULL;
1293         }
1294
1295         memset( c, 0, sizeof ( CLIENT ));
1296
1297         c->type = CLIENT_UNKNOWN;
1298         c->conn_id = NONE;
1299         c->oper_by_me = false;
1300         c->hops = -1;
1301         c->token = -1;
1302         c->mytoken = -1;
1303
1304         return c;
1305 } /* New_Client */
1306
1307
1308 static void
1309 Generate_MyToken( CLIENT *Client )
1310 {
1311         CLIENT *c;
1312         int token;
1313
1314         c = My_Clients;
1315         token = 2;
1316         while( c )
1317         {
1318                 if( c->mytoken == token )
1319                 {
1320                         /* Das Token wurde bereits vergeben */
1321                         token++;
1322                         c = My_Clients;
1323                         continue;
1324                 }
1325                 else c = (CLIENT *)c->next;
1326         }
1327         Client->mytoken = token;
1328         LogDebug("Assigned token %d to server \"%s\".", token, Client->id);
1329 } /* Generate_MyToken */
1330
1331
1332 static void
1333 Adjust_Counters( CLIENT *Client )
1334 {
1335         long count;
1336
1337         assert( Client != NULL );
1338
1339         if( Client->type != CLIENT_USER ) return;
1340
1341         if( Client->conn_id != NONE )
1342         {
1343                 /* Local connection */
1344                 count = Client_MyUserCount( );
1345                 if( count > My_Max_Users ) My_Max_Users = count;
1346         }
1347         count = Client_UserCount( );
1348         if( count > Max_Users ) Max_Users = count;
1349 } /* Adjust_Counters */
1350
1351
1352 /**
1353  * Register client in My_Whowas structure for further recall by WHOWAS.
1354  * Note: Only clients that have been connected at least 30 seconds will be
1355  * registered to prevent automated IRC bots to "destroy" a nice server
1356  * history database.
1357  */
1358 GLOBAL void
1359 Client_RegisterWhowas( CLIENT *Client )
1360 {
1361         int slot;
1362         time_t now;
1363
1364         assert( Client != NULL );
1365
1366         /* Don't register WHOWAS information when "MorePrivacy" is enabled. */
1367         if (Conf_MorePrivacy)
1368                 return;
1369
1370         now = time(NULL);
1371         /* Don't register clients that were connected less than 30 seconds. */
1372         if( now - Client->starttime < 30 )
1373                 return;
1374
1375         slot = Last_Whowas + 1;
1376         if( slot >= MAX_WHOWAS || slot < 0 ) slot = 0;
1377
1378 #ifdef DEBUG
1379         Log( LOG_DEBUG, "Saving WHOWAS information to slot %d ...", slot );
1380 #endif
1381
1382         My_Whowas[slot].time = now;
1383         strlcpy( My_Whowas[slot].id, Client_ID( Client ),
1384                  sizeof( My_Whowas[slot].id ));
1385         strlcpy( My_Whowas[slot].user, Client_User( Client ),
1386                  sizeof( My_Whowas[slot].user ));
1387         strlcpy( My_Whowas[slot].host, Client_HostnameDisplayed( Client ),
1388                  sizeof( My_Whowas[slot].host ));
1389         strlcpy( My_Whowas[slot].info, Client_Info( Client ),
1390                  sizeof( My_Whowas[slot].info ));
1391         strlcpy( My_Whowas[slot].server, Client_ID( Client_Introducer( Client )),
1392                  sizeof( My_Whowas[slot].server ));
1393
1394         Last_Whowas = slot;
1395 } /* Client_RegisterWhowas */
1396
1397
1398 GLOBAL const char *
1399 Client_TypeText(CLIENT *Client)
1400 {
1401         assert(Client != NULL);
1402         switch (Client_Type(Client)) {
1403                 case CLIENT_USER:
1404                         return "User";
1405                         break;
1406                 case CLIENT_SERVICE:
1407                         return "Service";
1408                         break;
1409                 case CLIENT_SERVER:
1410                         return "Server";
1411                         break;
1412                 default:
1413                         return "Client";
1414         }
1415 } /* Client_TypeText */
1416
1417
1418 /**
1419  * Destroy user or service client.
1420  */
1421 static void
1422 Destroy_UserOrService(CLIENT *Client, const char *Txt, const char *FwdMsg, bool SendQuit)
1423 {
1424         if(Client->conn_id != NONE) {
1425                 /* Local (directly connected) client */
1426                 Log(LOG_NOTICE,
1427                     "%s \"%s\" unregistered (connection %d): %s",
1428                     Client_TypeText(Client), Client_Mask(Client),
1429                     Client->conn_id, Txt);
1430                 Log_ServerNotice('c', "Client exiting: %s (%s@%s) [%s]",
1431                                  Client_ID(Client), Client_User(Client),
1432                                  Client_Hostname(Client), Txt);
1433
1434                 if (SendQuit) {
1435                         /* Inforam all the other servers */
1436                         if (FwdMsg)
1437                                 IRC_WriteStrServersPrefix(NULL,
1438                                                 Client, "QUIT :%s", FwdMsg );
1439                         else
1440                                 IRC_WriteStrServersPrefix(NULL,
1441                                                 Client, "QUIT :");
1442                 }
1443         } else {
1444                 /* Remote client */
1445                 LogDebug("%s \"%s\" unregistered: %s",
1446                          Client_TypeText(Client), Client_Mask(Client), Txt);
1447
1448                 if(SendQuit) {
1449                         /* Inform all the other servers, but the ones in the
1450                          * direction we got the QUIT from */
1451                         if(FwdMsg)
1452                                 IRC_WriteStrServersPrefix(Client_NextHop(Client),
1453                                                 Client, "QUIT :%s", FwdMsg );
1454                         else
1455                                 IRC_WriteStrServersPrefix(Client_NextHop(Client),
1456                                                 Client, "QUIT :" );
1457                 }
1458         }
1459
1460         /* Unregister client from channels */
1461         Channel_Quit(Client, FwdMsg ? FwdMsg : Client->id);
1462
1463         /* Register client in My_Whowas structure */
1464         Client_RegisterWhowas(Client);
1465 } /* Destroy_UserOrService */
1466
1467
1468 /**
1469  * Introduce a new user or service client to a remote server.
1470  *
1471  * This function differentiates between RFC1459 and RFC2813 server links and
1472  * generates the appropriate commands to register the new user or service.
1473  *
1474  * @param To            The remote server to inform.
1475  * @param Prefix        Prefix for the generated commands.
1476  * @param data          CLIENT structure of the new client.
1477  */
1478 static void
1479 cb_introduceClient(CLIENT *To, CLIENT *Prefix, void *data)
1480 {
1481         CLIENT *c = (CLIENT *)data;
1482         CONN_ID conn;
1483         char *modes, *user, *host;
1484
1485         modes = Client_Modes(c);
1486         user = Client_User(c) ? Client_User(c) : "-";
1487         host = Client_Hostname(c) ? Client_Hostname(c) : "-";
1488
1489         conn = Client_Conn(To);
1490         if (Conn_Options(conn) & CONN_RFC1459) {
1491                 /* RFC 1459 mode: separate NICK and USER commands */
1492                 Conn_WriteStr(conn, "NICK %s :%d", Client_ID(c),
1493                               Client_Hops(c) + 1);
1494                 Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
1495                               Client_ID(c), user, host,
1496                               Client_ID(Client_Introducer(c)), Client_Info(c));
1497                 if (modes[0])
1498                         Conn_WriteStr(conn, ":%s MODE %s +%s",
1499                                       Client_ID(c), Client_ID(c), modes);
1500         } else {
1501                 /* RFC 2813 mode: one combined NICK or SERVICE command */
1502                 if (Client_Type(c) == CLIENT_SERVICE
1503                     && strchr(Client_Flags(To), 'S'))
1504                         IRC_WriteStrClientPrefix(To, Prefix,
1505                                                  "SERVICE %s %d * +%s %d :%s",
1506                                                  Client_Mask(c),
1507                                                  Client_MyToken(Client_Introducer(c)),
1508                                                  Client_Modes(c), Client_Hops(c) + 1,
1509                                                  Client_Info(c));
1510                 else
1511                         IRC_WriteStrClientPrefix(To, Prefix,
1512                                                  "NICK %s %d %s %s %d +%s :%s",
1513                                                  Client_ID(c), Client_Hops(c) + 1,
1514                                                  user, host,
1515                                                  Client_MyToken(Client_Introducer(c)),
1516                                                  modes, Client_Info(c));
1517         }
1518 } /* cb_introduceClient */
1519
1520
1521 #ifdef DEBUG
1522
1523 GLOBAL void
1524 Client_DebugDump(void)
1525 {
1526         CLIENT *c;
1527
1528         Log(LOG_DEBUG, "Client status:");
1529         c = My_Clients;
1530         while (c) {
1531                 Log(LOG_DEBUG,
1532                     " - %s: type=%d, host=%s, user=%s, conn=%d, start=%ld, flags=%s",
1533                    Client_ID(c), Client_Type(c), Client_Hostname(c),
1534                    Client_User(c), Client_Conn(c), Client_StartTime(c),
1535                    Client_Flags(c));
1536                 c = (CLIENT *)c->next;
1537         }
1538 } /* Client_DumpClients */
1539
1540 #endif
1541
1542
1543 /* -eof- */