ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/client.c
Revision: 885
Committed: Wed Oct 31 18:09:24 2007 UTC (18 years, 8 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/src/client.c
File size: 42485 byte(s)
Log Message:
- Removed LazyLinks in 7.2 to stop people from asking why we keep
  broken code for half a decade. LL will be implemented in a smarter
  fashion in due time

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

Properties

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