ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/src/client.c
Revision: 849
Committed: Mon Feb 19 19:41:59 2007 UTC (18 years, 6 months ago) by db
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/src/client.c
File size: 42812 byte(s)
Log Message:
- Add +C 
- add etrace -full

Reviewed by: cryogen, bear

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * client.c: Controls clients.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "tools.h"
27     #include "client.h"
28     #include "channel_mode.h"
29     #include "common.h"
30     #include "event.h"
31     #include "fdlist.h"
32     #include "hash.h"
33     #include "irc_string.h"
34     #include "sprintf_irc.h"
35     #include "ircd.h"
36     #include "list.h"
37     #include "s_gline.h"
38     #include "numeric.h"
39     #include "packet.h"
40     #include "s_auth.h"
41     #include "s_bsd.h"
42     #include "s_conf.h"
43     #include "s_log.h"
44     #include "s_misc.h"
45     #include "s_serv.h"
46     #include "send.h"
47     #include "whowas.h"
48     #include "s_user.h"
49     #include "dbuf.h"
50     #include "memory.h"
51     #include "hostmask.h"
52     #include "balloc.h"
53     #include "listener.h"
54     #include "irc_res.h"
55     #include "userhost.h"
56    
57     dlink_list listing_client_list = { NULL, NULL, 0 };
58     /* Pointer to beginning of Client list */
59     dlink_list global_client_list = {NULL, NULL, 0};
60     /* unknown/client pointer lists */
61     dlink_list unknown_list = {NULL, NULL, 0};
62     dlink_list local_client_list = {NULL, NULL, 0};
63     dlink_list serv_list = {NULL, NULL, 0};
64     dlink_list global_serv_list = {NULL, NULL, 0};
65     dlink_list oper_list = {NULL, NULL, 0};
66    
67     static EVH check_pings;
68    
69     static BlockHeap *client_heap = NULL;
70     static BlockHeap *lclient_heap = NULL;
71    
72     static dlink_list dead_list = { NULL, NULL, 0};
73     static dlink_list abort_list = { NULL, NULL, 0};
74    
75     static dlink_node *eac_next; /* next aborted client to exit */
76    
77     static void check_pings_list(dlink_list *);
78     static void check_unknowns_list(void);
79     static void ban_them(struct Client *client_p, struct ConfItem *conf);
80    
81    
82     /* init_client()
83     *
84     * inputs - NONE
85     * output - NONE
86     * side effects - initialize client free memory
87     */
88     void
89     init_client(void)
90     {
91     /* start off the check ping event .. -- adrian
92     * Every 30 seconds is plenty -- db
93     */
94     client_heap = BlockHeapCreate("client", sizeof(struct Client), CLIENT_HEAP_SIZE);
95     lclient_heap = BlockHeapCreate("local client", sizeof(struct LocalUser), LCLIENT_HEAP_SIZE);
96     eventAdd("check_pings", check_pings, NULL, 5);
97     }
98    
99     /*
100     * make_client - create a new Client struct and set it to initial state.
101     *
102     * from == NULL, create local client (a client connected
103     * to a socket).
104     * WARNING: This leaves the client in a dangerous
105     * state where fd == -1, dead flag is not set and
106     * the client is on the unknown_list; therefore,
107     * the first thing to do after calling make_client(NULL)
108     * is setting fd to something reasonable. -adx
109     *
110     * from, create remote client (behind a socket
111     * associated with the client defined by
112     * 'from'). ('from' is a local client!!).
113     */
114     struct Client *
115     make_client(struct Client *from)
116     {
117     struct Client *client_p = BlockHeapAlloc(client_heap);
118    
119     if (from == NULL)
120     {
121     client_p->from = client_p; /* 'from' of local client is self! */
122     client_p->since = client_p->lasttime = client_p->firsttime = CurrentTime;
123    
124     client_p->localClient = BlockHeapAlloc(lclient_heap);
125 michael 503 client_p->localClient->registration = REG_INIT;
126 adx 30 /* as good a place as any... */
127     dlinkAdd(client_p, make_dlink_node(), &unknown_list);
128     }
129     else
130     client_p->from = from; /* 'from' of local client is self! */
131    
132     client_p->hnext = client_p;
133     client_p->status = STAT_UNKNOWN;
134     strcpy(client_p->username, "unknown");
135    
136     return client_p;
137     }
138    
139     /*
140     * free_client
141     *
142     * inputs - pointer to client
143     * output - NONE
144     * side effects - client pointed to has its memory freed
145     */
146     static void
147     free_client(struct Client *client_p)
148     {
149     assert(client_p != NULL);
150     assert(client_p != &me);
151     assert(client_p->hnext == client_p);
152     assert(client_p->channel.head == NULL);
153     assert(dlink_list_length(&client_p->channel) == 0);
154    
155     MyFree(client_p->away);
156     MyFree(client_p->serv);
157    
158     if (MyConnect(client_p))
159     {
160 michael 317 assert(client_p->localClient->invited.head == NULL);
161     assert(dlink_list_length(&client_p->localClient->invited) == 0);
162 adx 30 assert(IsClosing(client_p) && IsDead(client_p));
163    
164     MyFree(client_p->localClient->response);
165     MyFree(client_p->localClient->auth_oper);
166    
167     /*
168     * clean up extra sockets from P-lines which have been discarded.
169     */
170     if (client_p->localClient->listener)
171     {
172     assert(0 < client_p->localClient->listener->ref_count);
173     if (0 == --client_p->localClient->listener->ref_count &&
174     !client_p->localClient->listener->active)
175     free_listener(client_p->localClient->listener);
176     }
177    
178     dbuf_clear(&client_p->localClient->buf_recvq);
179     dbuf_clear(&client_p->localClient->buf_sendq);
180    
181     BlockHeapFree(lclient_heap, client_p->localClient);
182     }
183    
184     BlockHeapFree(client_heap, client_p);
185     }
186    
187     /*
188     * check_pings - go through the local client list and check activity
189     * kill off stuff that should die
190     *
191     * inputs - NOT USED (from event)
192     * output - next time_t when check_pings() should be called again
193     * side effects -
194     *
195     *
196     * A PING can be sent to clients as necessary.
197     *
198     * Client/Server ping outs are handled.
199     */
200    
201     /*
202     * Addon from adrian. We used to call this after nextping seconds,
203     * however I've changed it to run once a second. This is only for
204     * PING timeouts, not K/etc-line checks (thanks dianora!). Having it
205     * run once a second makes life a lot easier - when a new client connects
206     * and they need a ping in 4 seconds, if nextping was set to 20 seconds
207     * we end up waiting 20 seconds. This is stupid. :-)
208     * I will optimise (hah!) check_pings() once I've finished working on
209     * tidying up other network IO evilnesses.
210     * -- adrian
211     */
212    
213     static void
214     check_pings(void *notused)
215     {
216     check_pings_list(&local_client_list);
217     check_pings_list(&serv_list);
218     check_unknowns_list();
219     }
220    
221     /* check_pings_list()
222     *
223     * inputs - pointer to list to check
224     * output - NONE
225     * side effects -
226     */
227     static void
228     check_pings_list(dlink_list *list)
229     {
230     char scratch[32]; /* way too generous but... */
231     struct Client *client_p; /* current local client_p being examined */
232     int ping, pingwarn; /* ping time value from client */
233     dlink_node *ptr, *next_ptr;
234    
235     DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
236     {
237     client_p = ptr->data;
238    
239     /*
240     ** Note: No need to notify opers here. It's
241     ** already done when "FLAGS_DEADSOCKET" is set.
242     */
243     if (IsDead(client_p))
244     {
245     /* Ignore it, its been exited already */
246     continue;
247     }
248    
249     if (client_p->localClient->reject_delay > 0)
250     {
251     if (client_p->localClient->reject_delay <= CurrentTime)
252     exit_client(client_p, &me, "Rejected");
253     continue;
254     }
255    
256     if (GlobalSetOptions.idletime && IsClient(client_p))
257     {
258     if (!IsExemptKline(client_p) && !IsOper(client_p) &&
259     !IsIdlelined(client_p) &&
260     ((CurrentTime - client_p->localClient->last) > GlobalSetOptions.idletime))
261     {
262     struct ConfItem *conf;
263     struct AccessItem *aconf;
264    
265     conf = make_conf_item(KLINE_TYPE);
266     aconf = (struct AccessItem *)map_to_conf(conf);
267    
268     DupString(aconf->host, client_p->host);
269     DupString(aconf->reason, "idle exceeder");
270     DupString(aconf->user, client_p->username);
271     aconf->hold = CurrentTime + 60;
272     add_temp_line(conf);
273    
274     sendto_realops_flags(UMODE_ALL, L_ALL,
275     "Idle time limit exceeded for %s - temp k-lining",
276     get_client_name(client_p, HIDE_IP));
277     exit_client(client_p, &me, aconf->reason);
278     continue;
279     }
280     }
281    
282     if (!IsRegistered(client_p))
283     ping = CONNECTTIMEOUT, pingwarn = 0;
284     else
285     ping = get_client_ping(client_p, &pingwarn);
286    
287     if (ping < CurrentTime - client_p->lasttime)
288     {
289     if (!IsPingSent(client_p))
290     {
291     /*
292     * if we havent PINGed the connection and we havent
293     * heard from it in a while, PING it to make sure
294     * it is still alive.
295     */
296     SetPingSent(client_p);
297     ClearPingWarning(client_p);
298     client_p->lasttime = CurrentTime - ping;
299     sendto_one(client_p, "PING :%s", ID_or_name(&me, client_p));
300     }
301     else
302     {
303     if (CurrentTime - client_p->lasttime >= 2 * ping)
304     {
305     /*
306     * If the client/server hasn't talked to us in 2*ping seconds
307     * and it has a ping time, then close its connection.
308     */
309     if (IsServer(client_p) || IsHandshake(client_p))
310     {
311     sendto_realops_flags(UMODE_ALL, L_ADMIN,
312     "No response from %s, closing link",
313     get_client_name(client_p, HIDE_IP));
314     sendto_realops_flags(UMODE_ALL, L_OPER,
315     "No response from %s, closing link",
316     get_client_name(client_p, MASK_IP));
317     ilog(L_NOTICE, "No response from %s, closing link",
318     get_client_name(client_p, HIDE_IP));
319     }
320 michael 650
321 adx 30 ircsprintf(scratch, "Ping timeout: %d seconds",
322     (int)(CurrentTime - client_p->lasttime));
323     exit_client(client_p, &me, scratch);
324     }
325     else if (!IsPingWarning(client_p) && pingwarn > 0 &&
326     (IsServer(client_p) || IsHandshake(client_p)) &&
327     CurrentTime - client_p->lasttime >= ping + pingwarn)
328     {
329     /*
330     * If the server hasn't replied in pingwarn seconds after sending
331     * the PING, notify the opers so that they are aware of the problem.
332     */
333     SetPingWarning(client_p);
334     sendto_realops_flags(UMODE_ALL, L_ADMIN,
335     "Warning, no response from %s in %d seconds",
336     get_client_name(client_p, HIDE_IP), pingwarn);
337     sendto_realops_flags(UMODE_ALL, L_OPER,
338     "Warning, no response from %s in %d seconds",
339     get_client_name(client_p, MASK_IP), pingwarn);
340     ilog(L_NOTICE, "No response from %s in %d seconds",
341     get_client_name(client_p, HIDE_IP), pingwarn);
342     }
343     }
344     }
345     }
346     }
347    
348     /* check_unknowns_list()
349     *
350     * inputs - pointer to list of unknown clients
351     * output - NONE
352     * side effects - unknown clients get marked for termination after n seconds
353     */
354     static void
355     check_unknowns_list(void)
356     {
357     dlink_node *ptr, *next_ptr;
358    
359     DLINK_FOREACH_SAFE(ptr, next_ptr, unknown_list.head)
360     {
361     struct Client *client_p = ptr->data;
362    
363     if (client_p->localClient->reject_delay > 0)
364     {
365     if (client_p->localClient->reject_delay <= CurrentTime)
366 michael 650 exit_client(client_p, &me, "Rejected");
367 adx 30 continue;
368     }
369    
370 michael 650 /*
371     * Check UNKNOWN connections - if they have been in this state
372 adx 30 * for > 30s, close them.
373     */
374 michael 650 if (IsAuthFinished(client_p) && (CurrentTime - client_p->firsttime) > 30)
375     exit_client(client_p, &me, "Registration timed out");
376 adx 30 }
377     }
378    
379     /* check_conf_klines()
380     *
381     * inputs - NONE
382     * output - NONE
383     * side effects - Check all connections for a pending kline against the
384     * client, exit the client if a kline matches.
385     */
386     void
387     check_conf_klines(void)
388     {
389     struct Client *client_p = NULL; /* current local client_p being examined */
390     struct AccessItem *aconf = NULL;
391     struct ConfItem *conf = NULL;
392     dlink_node *ptr, *next_ptr;
393    
394     DLINK_FOREACH_SAFE(ptr, next_ptr, local_client_list.head)
395     {
396     client_p = ptr->data;
397    
398     /* If a client is already being exited
399     */
400     if (IsDead(client_p) || !IsClient(client_p))
401     continue;
402    
403     /* if there is a returned struct ConfItem then kill it */
404     if ((aconf = find_dline_conf(&client_p->localClient->ip,
405     client_p->localClient->aftype)) != NULL)
406     {
407     if (aconf->status & CONF_EXEMPTDLINE)
408     continue;
409    
410     conf = unmap_conf_item(aconf);
411     ban_them(client_p, conf);
412     continue; /* and go examine next fd/client_p */
413     }
414    
415     if (ConfigFileEntry.glines && (aconf = find_gline(client_p)))
416     {
417     if (IsExemptKline(client_p) ||
418     IsExemptGline(client_p))
419     {
420     sendto_realops_flags(UMODE_ALL, L_ALL,
421     "GLINE over-ruled for %s, client is %sline_exempt",
422     get_client_name(client_p, HIDE_IP), IsExemptKline(client_p) ? "k" : "g");
423     continue;
424     }
425    
426     conf = unmap_conf_item(aconf);
427     ban_them(client_p, conf);
428     /* and go examine next fd/client_p */
429     continue;
430     }
431    
432     if ((aconf = find_kill(client_p)) != NULL)
433     {
434    
435     /* if there is a returned struct AccessItem.. then kill it */
436     if (IsExemptKline(client_p))
437     {
438     sendto_realops_flags(UMODE_ALL, L_ALL,
439     "KLINE over-ruled for %s, client is kline_exempt",
440     get_client_name(client_p, HIDE_IP));
441     continue;
442     }
443    
444     conf = unmap_conf_item(aconf);
445     ban_them(client_p, conf);
446     continue;
447     }
448    
449     /* if there is a returned struct MatchItem then kill it */
450     if ((conf = find_matching_name_conf(XLINE_TYPE, client_p->info,
451     NULL, NULL, 0)) != NULL ||
452     (conf = find_matching_name_conf(RXLINE_TYPE, client_p->info,
453     NULL, NULL, 0)) != NULL)
454     {
455     ban_them(client_p, conf);
456     continue;
457     }
458     }
459    
460     /* also check the unknowns list for new dlines */
461     DLINK_FOREACH_SAFE(ptr, next_ptr, unknown_list.head)
462     {
463     client_p = ptr->data;
464    
465     if ((aconf = find_dline_conf(&client_p->localClient->ip,
466     client_p->localClient->aftype)))
467     {
468     if (aconf->status & CONF_EXEMPTDLINE)
469     continue;
470    
471     exit_client(client_p, &me, "D-lined");
472     }
473     }
474     }
475    
476     /*
477     * ban_them
478     *
479     * inputs - pointer to client to ban
480     * - pointer to ConfItem
481     * output - NONE
482     * side effects - given client_p is banned
483     */
484     static void
485     ban_them(struct Client *client_p, struct ConfItem *conf)
486     {
487     const char *user_reason = NULL; /* What is sent to user */
488     const char *channel_reason = NULL; /* What is sent to channel */
489     struct AccessItem *aconf = NULL;
490     struct MatchItem *xconf = NULL;
491     const char *type_string = NULL;
492     const char dline_string[] = "D-line";
493     const char kline_string[] = "K-line";
494     const char gline_string[] = "G-line";
495     const char xline_string[] = "X-line";
496    
497     switch (conf->type)
498     {
499     case RKLINE_TYPE:
500     case KLINE_TYPE:
501     type_string = kline_string;
502     aconf = map_to_conf(conf);
503     break;
504     case DLINE_TYPE:
505     type_string = dline_string;
506     aconf = map_to_conf(conf);
507     break;
508     case GLINE_TYPE:
509     type_string = gline_string;
510     aconf = map_to_conf(conf);
511     break;
512     case RXLINE_TYPE:
513     case XLINE_TYPE:
514     type_string = xline_string;
515     xconf = map_to_conf(conf);
516     ++xconf->count;
517     break;
518     default:
519     assert(0);
520     break;
521     }
522    
523     if (ConfigFileEntry.kline_with_reason)
524     {
525     if (aconf != NULL)
526     user_reason = aconf->reason ? aconf->reason : type_string;
527     if (xconf != NULL)
528     user_reason = xconf->reason ? xconf->reason : type_string;
529     }
530     else
531     user_reason = type_string;
532    
533     if (ConfigFileEntry.kline_reason != NULL)
534     channel_reason = ConfigFileEntry.kline_reason;
535     else
536     channel_reason = user_reason;
537    
538     sendto_realops_flags(UMODE_ALL, L_ALL, "%s active for %s",
539     type_string, get_client_name(client_p, HIDE_IP));
540    
541     if (IsClient(client_p))
542     sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
543     me.name, client_p->name, user_reason);
544    
545     exit_client(client_p, &me, channel_reason);
546     }
547    
548     /* update_client_exit_stats()
549     *
550     * input - pointer to client
551     * output - NONE
552     * side effects -
553     */
554     static void
555     update_client_exit_stats(struct Client *client_p)
556     {
557     if (IsServer(client_p))
558     {
559     sendto_realops_flags(UMODE_EXTERNAL, L_ALL,
560     "Server %s split from %s",
561     client_p->name, client_p->servptr->name);
562     }
563     else if (IsClient(client_p))
564     {
565     --Count.total;
566     if (IsOper(client_p))
567     --Count.oper;
568     if (IsInvisible(client_p))
569     --Count.invisi;
570     }
571    
572     if (splitchecking && !splitmode)
573     check_splitmode(NULL);
574     }
575    
576     /* find_person()
577     *
578     * inputs - pointer to name
579     * output - return client pointer
580     * side effects - find person by (nick)name
581     */
582     /* XXX - ugly wrapper */
583     struct Client *
584     find_person(const struct Client *client_p, const char *name)
585     {
586     struct Client *c2ptr;
587    
588     if (IsDigit(*name))
589     {
590     if ((c2ptr = hash_find_id(name)) != NULL)
591     {
592     /* invisible users shall not be found by UID guessing */
593     if (IsInvisible(c2ptr) && !IsServer(client_p))
594     c2ptr = NULL;
595     }
596     }
597     else
598     c2ptr = find_client(name);
599    
600     return ((c2ptr != NULL && IsClient(c2ptr)) ? c2ptr : NULL);
601     }
602    
603     /*
604     * find_chasing - find the client structure for a nick name (user)
605     * using history mechanism if necessary. If the client is not found,
606     * an error message (NO SUCH NICK) is generated. If the client was found
607     * through the history, chasing will be 1 and otherwise 0.
608     */
609     struct Client *
610     find_chasing(struct Client *client_p, struct Client *source_p, const char *user, int *chasing)
611     {
612     struct Client *who = find_person(client_p, user);
613    
614     if (chasing)
615     *chasing = 0;
616    
617     if (who)
618     return(who);
619    
620     if (IsDigit(*user))
621     return(NULL);
622    
623     if ((who = get_history(user,
624     (time_t)ConfigFileEntry.kill_chase_time_limit))
625     == NULL)
626     {
627     sendto_one(source_p, form_str(ERR_NOSUCHNICK),
628     me.name, source_p->name, user);
629     return(NULL);
630     }
631    
632     if (chasing)
633     *chasing = 1;
634    
635     return(who);
636     }
637    
638     /*
639     * get_client_name - Return the name of the client
640     * for various tracking and
641     * admin purposes. The main purpose of this function is to
642     * return the "socket host" name of the client, if that
643     * differs from the advertised name (other than case).
644     * But, this can be used to any client structure.
645     *
646     * NOTE 1:
647     * Watch out the allocation of "nbuf", if either source_p->name
648     * or source_p->sockhost gets changed into pointers instead of
649     * directly allocated within the structure...
650     *
651     * NOTE 2:
652     * Function return either a pointer to the structure (source_p) or
653     * to internal buffer (nbuf). *NEVER* use the returned pointer
654     * to modify what it points!!!
655     */
656     const char *
657     get_client_name(struct Client *client, int showip)
658     {
659     static char nbuf[HOSTLEN * 2 + USERLEN + 5];
660    
661     assert(client != NULL);
662    
663     if (irccmp(client->name, client->host) == 0)
664     return(client->name);
665    
666     if (ConfigServerHide.hide_server_ips)
667     if (IsServer(client) || IsConnecting(client) || IsHandshake(client))
668     showip = MASK_IP;
669    
670     if (ConfigFileEntry.hide_spoof_ips)
671     if (showip == SHOW_IP && IsIPSpoof(client))
672     showip = MASK_IP;
673    
674     /* And finally, let's get the host information, ip or name */
675     switch (showip)
676     {
677     case SHOW_IP:
678     if (MyConnect(client))
679     {
680     ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
681     client->sockhost);
682     break;
683     }
684     case MASK_IP:
685     ircsprintf(nbuf, "%s[%s@255.255.255.255]", client->name,
686     client->username);
687     break;
688     default:
689     ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
690     client->host);
691     }
692    
693     return(nbuf);
694     }
695    
696     void
697     free_exited_clients(void)
698     {
699     dlink_node *ptr, *next;
700     struct Client *target_p;
701    
702     DLINK_FOREACH_SAFE(ptr, next, dead_list.head)
703     {
704     target_p = ptr->data;
705    
706     if (ptr->data == NULL)
707     {
708     sendto_realops_flags(UMODE_ALL, L_ALL,
709     "Warning: null client on dead_list!");
710     dlinkDelete(ptr, &dead_list);
711     free_dlink_node(ptr);
712     continue;
713     }
714    
715     free_client(target_p);
716     dlinkDelete(ptr, &dead_list);
717     free_dlink_node(ptr);
718     }
719     }
720    
721     /*
722     * Exit one client, local or remote. Assuming all dependents have
723     * been already removed, and socket closed for local client.
724     *
725     * The only messages generated are QUITs on channels.
726     */
727     static void
728     exit_one_client(struct Client *source_p, const char *quitmsg)
729     {
730     dlink_node *lp = NULL, *next_lp = NULL;
731    
732     assert(!IsMe(source_p));
733    
734     if (IsServer(source_p))
735     {
736     dlinkDelete(&source_p->lnode, &source_p->servptr->serv->servers);
737    
738     if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL)
739     free_dlink_node(lp);
740    
741     if (!MyConnect(source_p))
742     {
743     source_p->from->serv->dep_servers--;
744     assert(source_p->from->serv->dep_servers > 0);
745     }
746     }
747     else if (IsClient(source_p))
748     {
749     if (source_p->servptr->serv != NULL)
750     dlinkDelete(&source_p->lnode, &source_p->servptr->serv->users);
751    
752     /* If a person is on a channel, send a QUIT notice
753     ** to every client (person) on the same channel (so
754     ** that the client can show the "**signoff" message).
755     ** (Note: The notice is to the local clients *only*)
756     */
757     sendto_common_channels_local(source_p, 0, ":%s!%s@%s QUIT :%s",
758     source_p->name, source_p->username,
759     source_p->host, quitmsg);
760     DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head)
761     remove_user_from_channel(lp->data);
762    
763     /* Clean up allow lists */
764     del_all_accepts(source_p);
765     add_history(source_p, 0);
766     off_history(source_p);
767    
768     if (!MyConnect(source_p))
769     {
770     source_p->from->serv->dep_users--;
771     assert(source_p->from->serv->dep_users >= 0);
772     }
773 michael 317 else
774     {
775     /* Clean up invitefield */
776     DLINK_FOREACH_SAFE(lp, next_lp, source_p->localClient->invited.head)
777     del_invite(lp->data, source_p);
778     }
779 adx 30 }
780    
781     /* Remove source_p from the client lists */
782     if (HasID(source_p))
783     hash_del_id(source_p);
784     if (source_p->name[0])
785     hash_del_client(source_p);
786    
787     if (IsUserHostIp(source_p))
788     delete_user_host(source_p->username, source_p->host, !MyConnect(source_p));
789    
790     /* remove from global client list
791     * NOTE: source_p->node.next cannot be NULL if the client is added
792     * to global_client_list (there is always &me at its end)
793     */
794     if (source_p != NULL && source_p->node.next != NULL)
795     dlinkDelete(&source_p->node, &global_client_list);
796    
797     update_client_exit_stats(source_p);
798    
799     /* Check to see if the client isn't already on the dead list */
800     assert(dlinkFind(&dead_list, source_p) == NULL);
801    
802     /* add to dead client dlist */
803     SetDead(source_p);
804     dlinkAdd(source_p, make_dlink_node(), &dead_list);
805     }
806    
807     /* Recursively send QUITs and SQUITs for source_p and all its dependent clients
808     * and servers to those servers that need them. A server needs the client
809     * QUITs if it can't figure them out from the SQUIT (ie pre-TS4) or if it
810     * isn't getting the SQUIT because of @#(*&@)# hostmasking. With TS4, once
811     * a link gets a SQUIT, it doesn't need any QUIT/SQUITs for clients depending
812     * on that one -orabidoo
813     *
814     * This is now called on each local server -adx
815     */
816     static void
817     recurse_send_quits(struct Client *original_source_p, struct Client *source_p,
818     struct Client *from, struct Client *to, const char *comment,
819     const char *splitstr, const char *myname)
820     {
821     dlink_node *ptr, *next;
822     struct Client *target_p;
823     int hidden = match(myname, source_p->name);
824    
825     assert(to != source_p); /* should be already removed from serv_list */
826    
827     /* If this server can handle quit storm (QS) removal
828     * of dependents, just send the SQUIT
829     *
830     * Always check *all* dependent servers if some of them are
831     * hidden behind fakename. If so, send out the QUITs -adx
832     */
833     if (hidden || !IsCapable(to, CAP_QS))
834     DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head)
835     {
836     target_p = ptr->data;
837     sendto_one(to, ":%s QUIT :%s", target_p->name, splitstr);
838     }
839    
840     DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head)
841     recurse_send_quits(original_source_p, ptr->data, from, to,
842     comment, splitstr, myname);
843    
844     if (!hidden && ((source_p == original_source_p && to != from) ||
845     !IsCapable(to, CAP_QS)))
846     {
847     /* don't use a prefix here - we have to be 100% sure the message
848     * will be accepted without Unknown prefix etc.. */
849     sendto_one(to, "SQUIT %s :%s", ID_or_name(source_p, to), comment);
850     }
851     }
852    
853     /*
854     * Remove all clients that depend on source_p; assumes all (S)QUITs have
855     * already been sent. we make sure to exit a server's dependent clients
856     * and servers before the server itself; exit_one_client takes care of
857     * actually removing things off llists. tweaked from +CSr31 -orabidoo
858     */
859     static void
860     recurse_remove_clients(struct Client *source_p, const char *quitmsg)
861     {
862     dlink_node *ptr, *next;
863    
864     DLINK_FOREACH_SAFE(ptr, next, source_p->serv->users.head)
865     exit_one_client(ptr->data, quitmsg);
866    
867     DLINK_FOREACH_SAFE(ptr, next, source_p->serv->servers.head)
868     {
869     recurse_remove_clients(ptr->data, quitmsg);
870     exit_one_client(ptr->data, quitmsg);
871     }
872    
873     assert(source_p->serv->dep_servers == 1);
874     assert(source_p->serv->dep_users == 0);
875     }
876    
877     /*
878     ** Remove *everything* that depends on source_p, from all lists, and sending
879     ** all necessary QUITs and SQUITs. source_p itself is still on the lists,
880     ** and its SQUITs have been sent except for the upstream one -orabidoo
881     */
882     static void
883     remove_dependents(struct Client *source_p, struct Client *from,
884     const char *comment, const char *splitstr)
885     {
886     struct Client *to;
887     struct ConfItem *conf;
888     static char myname[HOSTLEN+1];
889     dlink_node *ptr;
890    
891     DLINK_FOREACH(ptr, serv_list.head)
892     {
893     to = ptr->data;
894    
895     if ((conf = to->serv->sconf) != NULL)
896     strlcpy(myname, my_name_for_link(conf), sizeof(myname));
897     else
898     strlcpy(myname, me.name, sizeof(myname));
899     recurse_send_quits(source_p, source_p, from, to,
900     comment, splitstr, myname);
901     }
902    
903     recurse_remove_clients(source_p, splitstr);
904     }
905    
906     /*
907     * exit_client - exit a client of any type. Generally, you can use
908     * this on any struct Client, regardless of its state.
909     *
910     * Note, you shouldn't exit remote _users_ without first doing
911     * SetKilled and propagating a kill or similar message. However,
912     * it is perfectly correct to call exit_client to force a _server_
913     * quit (either local or remote one).
914     *
915     * inputs: - a client pointer that is going to be exited
916     * - for servers, the second argument is a pointer to who
917     * is firing the server. This side won't get any generated
918     * messages. NEVER NULL!
919     * output: none
920     * side effects: the client is delinked from all lists, disconnected,
921     * and the rest of IRC network is notified of the exit.
922     * Client memory is scheduled to be freed
923     */
924     void
925     exit_client(struct Client *source_p, struct Client *from, const char *comment)
926     {
927     dlink_node *m;
928    
929     if (MyConnect(source_p))
930     {
931     /* DO NOT REMOVE. exit_client can be called twice after a failed
932     * read/write.
933     */
934     if (IsClosing(source_p))
935     return;
936    
937     SetClosing(source_p);
938    
939     if (IsIpHash(source_p))
940     remove_one_ip(&source_p->localClient->ip);
941    
942     delete_auth(source_p);
943    
944     /* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING
945     * STAT_HANDSHAKE or STAT_UNKNOWN
946     * all of which are lumped together into unknown_list
947     *
948     * In all above cases IsRegistered() will not be true.
949     */
950     if (!IsRegistered(source_p))
951     {
952     if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL)
953     free_dlink_node(m);
954     }
955     else if (IsClient(source_p))
956     {
957     Count.local--;
958    
959     if (IsOper(source_p))
960     {
961     if ((m = dlinkFindDelete(&oper_list, source_p)) != NULL)
962     free_dlink_node(m);
963     }
964    
965     dlinkDelete(&source_p->localClient->lclient_node, &local_client_list);
966     if (source_p->localClient->list_task != NULL)
967     free_list_task(source_p->localClient->list_task, source_p);
968    
969     sendto_realops_flags(UMODE_CCONN, L_ALL, "Client exiting: %s (%s@%s) [%s] [%s]",
970     source_p->name, source_p->username, source_p->host, comment,
971     ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
972     "255.255.255.255" : source_p->sockhost);
973 db 849 sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, "CLIEXIT: %s %s %s %s %s",
974     source_p->name, source_p->username, source_p->host, comment,
975     ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
976     "255.255.255.255" : source_p->sockhost);
977 adx 30 }
978    
979     /* As soon as a client is known to be a server of some sort
980     * it has to be put on the serv_list, or SJOIN's to this new server
981     * from the connect burst will not be seen.
982     */
983     if (IsServer(source_p) || IsConnecting(source_p) ||
984     IsHandshake(source_p))
985     {
986     if ((m = dlinkFindDelete(&serv_list, source_p)) != NULL)
987     {
988     free_dlink_node(m);
989     unset_chcap_usage_counts(source_p);
990     }
991    
992     if (IsServer(source_p))
993     {
994     Count.myserver--;
995     if (ServerInfo.hub)
996     remove_lazylink_flags(source_p->localClient->serverMask);
997     else
998     uplink = NULL;
999     }
1000     }
1001    
1002     log_user_exit(source_p);
1003    
1004     if (!IsDead(source_p))
1005     {
1006     if (IsServer(source_p))
1007     {
1008     /* for them, we are exiting the network */
1009     sendto_one(source_p, ":%s SQUIT %s :%s",
1010     ID_or_name(from, source_p), me.name, comment);
1011     }
1012    
1013     sendto_one(source_p, "ERROR :Closing Link: %s (%s)",
1014     source_p->host, comment);
1015     }
1016    
1017     /*
1018     ** Currently only server connections can have
1019     ** depending remote clients here, but it does no
1020     ** harm to check for all local clients. In
1021     ** future some other clients than servers might
1022     ** have remotes too...
1023     **
1024     ** Close the Client connection first and mark it
1025     ** so that no messages are attempted to send to it.
1026     ** Remember it makes source_p->from == NULL.
1027     */
1028     close_connection(source_p);
1029     }
1030    
1031     if (IsServer(source_p))
1032     {
1033     char splitstr[HOSTLEN + HOSTLEN + 2];
1034    
1035     /* This shouldn't ever happen */
1036     assert(source_p->serv != NULL && source_p->servptr != NULL);
1037    
1038     if (ConfigServerHide.hide_servers)
1039     /* set netsplit message to "*.net *.split" to still show
1040     * that its a split, but hide the servers splitting
1041     */
1042     strcpy(splitstr, "*.net *.split");
1043     else
1044     snprintf(splitstr, sizeof(splitstr), "%s %s",
1045     source_p->servptr->name, source_p->name);
1046    
1047     remove_dependents(source_p, from->from, comment, splitstr);
1048    
1049     if (source_p->servptr == &me)
1050     {
1051     sendto_realops_flags(UMODE_ALL, L_ALL,
1052     "%s was connected for %d seconds. %llu/%llu sendK/recvK.",
1053     source_p->name, (int)(CurrentTime - source_p->firsttime),
1054     source_p->localClient->send.bytes >> 10,
1055     source_p->localClient->recv.bytes >> 10);
1056     ilog(L_NOTICE, "%s was connected for %d seconds. %llu/%llu sendK/recvK.",
1057     source_p->name, (int)(CurrentTime - source_p->firsttime),
1058     source_p->localClient->send.bytes >> 10,
1059     source_p->localClient->recv.bytes >> 10);
1060     }
1061     }
1062     else if (IsClient(source_p) && !IsKilled(source_p))
1063     {
1064 michael 498 sendto_server(from->from, source_p, NULL, CAP_TS6, NOCAPS, NOFLAGS,
1065 adx 30 ":%s QUIT :%s", ID(source_p), comment);
1066 michael 498 sendto_server(from->from, source_p, NULL, NOCAPS, CAP_TS6, NOFLAGS,
1067 adx 30 ":%s QUIT :%s", source_p->name, comment);
1068     }
1069    
1070     /* The client *better* be off all of the lists */
1071     assert(dlinkFind(&unknown_list, source_p) == NULL);
1072     assert(dlinkFind(&local_client_list, source_p) == NULL);
1073     assert(dlinkFind(&serv_list, source_p) == NULL);
1074     assert(dlinkFind(&oper_list, source_p) == NULL);
1075    
1076     exit_one_client(source_p, comment);
1077     }
1078    
1079     /*
1080     * dead_link_on_write - report a write error if not already dead,
1081     * mark it as dead then exit it
1082     */
1083     void
1084     dead_link_on_write(struct Client *client_p, int ierrno)
1085     {
1086     dlink_node *ptr;
1087    
1088     if (IsDefunct(client_p))
1089     return;
1090    
1091     dbuf_clear(&client_p->localClient->buf_recvq);
1092     dbuf_clear(&client_p->localClient->buf_sendq);
1093    
1094     assert(dlinkFind(&abort_list, client_p) == NULL);
1095     ptr = make_dlink_node();
1096     /* don't let exit_aborted_clients() finish yet */
1097     dlinkAddTail(client_p, ptr, &abort_list);
1098    
1099     if (eac_next == NULL)
1100     eac_next = ptr;
1101    
1102     SetDead(client_p); /* You are dead my friend */
1103     }
1104    
1105     /*
1106     * dead_link_on_read - report a read error if not already dead,
1107     * mark it as dead then exit it
1108     */
1109     void
1110     dead_link_on_read(struct Client *client_p, int error)
1111     {
1112     char errmsg[255];
1113     int current_error;
1114    
1115     if (IsDefunct(client_p))
1116     return;
1117    
1118     dbuf_clear(&client_p->localClient->buf_recvq);
1119     dbuf_clear(&client_p->localClient->buf_sendq);
1120    
1121     current_error = get_sockerr(client_p->localClient->fd.fd);
1122    
1123     if (IsServer(client_p) || IsHandshake(client_p))
1124     {
1125     int connected = CurrentTime - client_p->firsttime;
1126    
1127     if (error == 0)
1128     {
1129     /* Admins get the real IP */
1130     sendto_realops_flags(UMODE_ALL, L_ADMIN,
1131     "Server %s closed the connection",
1132     get_client_name(client_p, SHOW_IP));
1133    
1134     /* Opers get a masked IP */
1135     sendto_realops_flags(UMODE_ALL, L_OPER,
1136     "Server %s closed the connection",
1137     get_client_name(client_p, MASK_IP));
1138    
1139     ilog(L_NOTICE, "Server %s closed the connection",
1140     get_client_name(client_p, SHOW_IP));
1141     }
1142     else
1143     {
1144 michael 617 report_error(L_ADMIN, "Lost connection to %s: %s",
1145 adx 30 get_client_name(client_p, SHOW_IP), current_error);
1146 michael 617 report_error(L_OPER, "Lost connection to %s: %s",
1147 adx 30 get_client_name(client_p, MASK_IP), current_error);
1148     }
1149    
1150     sendto_realops_flags(UMODE_ALL, L_ALL,
1151     "%s had been connected for %d day%s, %2d:%02d:%02d",
1152     client_p->name, connected/86400,
1153     (connected/86400 == 1) ? "" : "s",
1154     (connected % 86400) / 3600, (connected % 3600) / 60,
1155     connected % 60);
1156     }
1157    
1158     if (error == 0)
1159     strlcpy(errmsg, "Remote host closed the connection",
1160     sizeof(errmsg));
1161     else
1162     ircsprintf(errmsg, "Read error: %s",
1163     strerror(current_error));
1164    
1165     exit_client(client_p, &me, errmsg);
1166     }
1167    
1168     void
1169     exit_aborted_clients(void)
1170     {
1171     dlink_node *ptr;
1172     struct Client *target_p;
1173     const char *notice;
1174    
1175     DLINK_FOREACH_SAFE(ptr, eac_next, abort_list.head)
1176     {
1177     target_p = ptr->data;
1178     eac_next = ptr->next;
1179    
1180     if (target_p == NULL)
1181     {
1182     sendto_realops_flags(UMODE_ALL, L_ALL,
1183     "Warning: null client on abort_list!");
1184     dlinkDelete(ptr, &abort_list);
1185     free_dlink_node(ptr);
1186     continue;
1187     }
1188    
1189     dlinkDelete(ptr, &abort_list);
1190    
1191     if (IsSendQExceeded(target_p))
1192     notice = "Max SendQ exceeded";
1193     else
1194     notice = "Write error: connection closed";
1195    
1196     exit_client(target_p, &me, notice);
1197     free_dlink_node(ptr);
1198     }
1199     }
1200    
1201     /*
1202     * accept processing, this adds a form of "caller ID" to ircd
1203     *
1204     * If a client puts themselves into "caller ID only" mode,
1205     * only clients that match a client pointer they have put on
1206     * the accept list will be allowed to message them.
1207     *
1208     * [ source.on_allow_list ] -> [ target1 ] -> [ target2 ]
1209     *
1210     * [target.allow_list] -> [ source1 ] -> [source2 ]
1211     *
1212     * i.e. a target will have a link list of source pointers it will allow
1213     * each source client then has a back pointer pointing back
1214     * to the client that has it on its accept list.
1215     * This allows for exit_one_client to remove these now bogus entries
1216     * from any client having an accept on them.
1217     */
1218    
1219     /* accept_message()
1220     *
1221     * inputs - pointer to source client
1222     * - pointer to target client
1223     * output - 1 if accept this message 0 if not
1224     * side effects - See if source is on target's allow list
1225     */
1226     int
1227     accept_message(struct Client *source, struct Client *target)
1228     {
1229     dlink_node *ptr;
1230    
1231     DLINK_FOREACH(ptr, target->allow_list.head)
1232     {
1233     struct Client *target_p = ptr->data;
1234    
1235     if (source == target_p)
1236     return (1);
1237     }
1238    
1239     if (IsSoftCallerId(target))
1240     {
1241     DLINK_FOREACH(ptr, target->channel.head)
1242 michael 384 if (IsMember(source, ((struct Membership *)ptr->data)->chptr))
1243 adx 30 return (1);
1244     }
1245    
1246     return (0);
1247     }
1248    
1249     /* del_from_accept()
1250     *
1251     * inputs - pointer to source client
1252     * - pointer to target client
1253     * output - NONE
1254     * side effects - Delete's source pointer to targets allow list
1255     *
1256     * Walk through the target's accept list, remove if source is found,
1257     * Then walk through the source's on_accept_list remove target if found.
1258     */
1259     void
1260     del_from_accept(struct Client *source, struct Client *target)
1261     {
1262     dlink_node *ptr;
1263     dlink_node *ptr2;
1264     dlink_node *next_ptr;
1265     dlink_node *next_ptr2;
1266     struct Client *target_p;
1267    
1268     DLINK_FOREACH_SAFE(ptr, next_ptr, target->allow_list.head)
1269     {
1270     target_p = ptr->data;
1271    
1272     if (source == target_p)
1273     {
1274     dlinkDelete(ptr, &target->allow_list);
1275     free_dlink_node(ptr);
1276    
1277     DLINK_FOREACH_SAFE(ptr2, next_ptr2, source->on_allow_list.head)
1278     {
1279     target_p = ptr2->data;
1280    
1281     if (target == target_p)
1282     {
1283     dlinkDelete(ptr2, &source->on_allow_list);
1284     free_dlink_node(ptr2);
1285     }
1286     }
1287     }
1288     }
1289     }
1290    
1291     /* del_all_accepts()
1292     *
1293     * inputs - pointer to exiting client
1294     * output - NONE
1295     * side effects - Walk through given clients allow_list and on_allow_list
1296     * remove all references to this client
1297     */
1298     void
1299     del_all_accepts(struct Client *client_p)
1300     {
1301     dlink_node *ptr, *next_ptr;
1302    
1303     DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->allow_list.head)
1304     del_from_accept(ptr->data, client_p);
1305    
1306     DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head)
1307     del_from_accept(client_p, ptr->data);
1308     }
1309    
1310     /* del_all_their_accepts()
1311     *
1312     * inputs - pointer to exiting client
1313     * output - NONE
1314     * side effects - Walk through given clients on_allow_list
1315     * remove all references to this client,
1316     * allow this client to keep their own allow_list
1317     */
1318     void
1319     del_all_their_accepts(struct Client *client_p)
1320     {
1321     dlink_node *ptr, *next_ptr;
1322    
1323     DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head)
1324     del_from_accept(client_p, ptr->data);
1325     }
1326    
1327     /* set_initial_nick()
1328     *
1329     * inputs
1330     * output
1331     * side effects -
1332     *
1333     * This function is only called to set up an initially registering
1334     * client.
1335     */
1336     void
1337     set_initial_nick(struct Client *client_p, struct Client *source_p,
1338     const char *nick)
1339     {
1340     char buf[USERLEN + 1];
1341    
1342     /* Client setting NICK the first time */
1343    
1344     /* This had to be copied here to avoid problems.. */
1345     source_p->tsinfo = CurrentTime;
1346 michael 503 source_p->localClient->registration &= ~REG_NEED_NICK;
1347 adx 30
1348     if (source_p->name[0])
1349     hash_del_client(source_p);
1350    
1351     strlcpy(source_p->name, nick, sizeof(source_p->name));
1352     hash_add_client(source_p);
1353    
1354     /* fd_desc is long enough */
1355     fd_note(&client_p->localClient->fd, "Nick: %s", nick);
1356    
1357     /* They have the nick they want now.. */
1358     client_p->llname[0] = '\0';
1359    
1360 michael 503 if (!source_p->localClient->registration)
1361 adx 30 {
1362     strlcpy(buf, source_p->username, sizeof(buf));
1363    
1364     /*
1365     * USER already received, now we have NICK.
1366     * *NOTE* For servers "NICK" *must* precede the
1367     * user message (giving USER before NICK is possible
1368     * only for local client connection!). register_user
1369     * may reject the client and call exit_client for it
1370     * --must test this and exit m_nick too!!!
1371     */
1372     register_local_user(client_p, source_p, nick, buf);
1373     }
1374     }
1375    
1376     /* change_local_nick()
1377     *
1378     * inputs - pointer to server
1379     * - pointer to client
1380     * - nick
1381     * output -
1382     * side effects - changes nick of a LOCAL user
1383     */
1384     void
1385     change_local_nick(struct Client *client_p, struct Client *source_p, const char *nick)
1386     {
1387     /*
1388     ** Client just changing his/her nick. If he/she is
1389     ** on a channel, send note of change to all clients
1390     ** on that channel. Propagate notice to other servers.
1391     */
1392     if ((source_p->localClient->last_nick_change +
1393     ConfigFileEntry.max_nick_time) < CurrentTime)
1394     source_p->localClient->number_of_nick_changes = 0;
1395     source_p->localClient->last_nick_change = CurrentTime;
1396     source_p->localClient->number_of_nick_changes++;
1397    
1398     if ((ConfigFileEntry.anti_nick_flood &&
1399     (source_p->localClient->number_of_nick_changes
1400     <= ConfigFileEntry.max_nick_changes)) ||
1401     !ConfigFileEntry.anti_nick_flood ||
1402     (IsOper(source_p) && ConfigFileEntry.no_oper_flood))
1403     {
1404     if (irccmp(source_p->name, nick))
1405 michael 706 {
1406     /*
1407     * Make sure everyone that has this client on its accept list
1408     * loses that reference.
1409     */
1410     del_all_their_accepts(source_p);
1411 adx 30 source_p->tsinfo = CurrentTime;
1412 michael 759 clear_ban_cache_client(source_p);
1413 michael 706 }
1414 adx 30
1415     /* XXX - the format of this notice should eventually be changed
1416     * to either %s[%s@%s], or even better would be get_client_name() -bill
1417     */
1418     sendto_realops_flags(UMODE_NCHANGE, L_ALL, "Nick change: From %s to %s [%s@%s]",
1419     source_p->name, nick, source_p->username, source_p->host);
1420     sendto_common_channels_local(source_p, 1, ":%s!%s@%s NICK :%s",
1421     source_p->name, source_p->username,
1422     source_p->host, nick);
1423 michael 706 add_history(source_p, 1);
1424 adx 30
1425 michael 706 /*
1426     * Only hubs care about lazy link nicks not being sent on yet
1427     * lazylink leafs/leafs always send their nicks up to hub,
1428     * hence must always propagate nick changes.
1429     * hubs might not propagate a nick change, if the leaf
1430     * does not know about that client yet.
1431     */
1432 adx 30 sendto_server(client_p, source_p, NULL, CAP_TS6, NOCAPS, NOFLAGS,
1433     ":%s NICK %s :%lu",
1434     ID(source_p), nick, (unsigned long)source_p->tsinfo);
1435     sendto_server(client_p, source_p, NULL, NOCAPS, CAP_TS6, NOFLAGS,
1436     ":%s NICK %s :%lu",
1437     source_p->name, nick, (unsigned long)source_p->tsinfo);
1438     }
1439     else
1440     {
1441     sendto_one(source_p, form_str(ERR_NICKTOOFAST),
1442     me.name, source_p->name, source_p->name,
1443     nick, ConfigFileEntry.max_nick_time);
1444     return;
1445     }
1446    
1447     /* Finally, add to hash */
1448     if (source_p->name[0])
1449     hash_del_client(source_p);
1450    
1451     strcpy(source_p->name, nick);
1452     hash_add_client(source_p);
1453    
1454     /* fd_desc is long enough */
1455     fd_note(&client_p->localClient->fd, "Nick: %s", nick);
1456     }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision