ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/client.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/client.c (file contents):
Revision 1785 by michael, Sat Jan 26 22:40:55 2013 UTC vs.
Revision 3207 by michael, Tue Mar 25 15:19:02 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  client.c: Controls clients.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file client.c
23 > * \brief Controls clients.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
# Line 52 | Line 54
54   #include "userhost.h"
55   #include "watch.h"
56   #include "rng_mt.h"
57 + #include "parse.h"
58  
59   dlink_list listing_client_list = { NULL, NULL, 0 };
60   /* Pointer to beginning of Client list */
# Line 75 | Line 78 | static dlink_node *eac_next;  /* next ab
78  
79   static void check_pings_list(dlink_list *);
80   static void check_unknowns_list(void);
78 static void ban_them(struct Client *, struct MaskItem *);
81  
82  
83 < /* init_client()
83 > /* client_init()
84   *
85   * inputs       - NONE
86   * output       - NONE
87   * side effects - initialize client free memory
88   */
89   void
90 < init_client(void)
90 > client_init(void)
91   {
92    /* start off the check ping event ..  -- adrian
93     * Every 30 seconds is plenty -- db
# Line 137 | Line 139 | make_client(struct Client *from)
139  
140    client_p->idhnext = client_p;
141    client_p->hnext  = client_p;
142 <  client_p->status = STAT_UNKNOWN;
142 >  SetUnknown(client_p);
143    strcpy(client_p->username, "unknown");
144    strcpy(client_p->svid, "0");
145  
# Line 164 | Line 166 | free_client(struct Client *client_p)
166    assert(!IsServer(client_p) || (IsServer(client_p) && client_p->serv));
167  
168    MyFree(client_p->serv);
169 +  MyFree(client_p->certfp);
170  
171    if (MyConnect(client_p))
172    {
173      assert(client_p->localClient->invited.head == NULL);
174      assert(dlink_list_length(&client_p->localClient->invited) == 0);
175 <    assert(dlink_list_length(&client_p->localClient->watches) == 0);
175 >    assert(dlink_list_length(&client_p->localClient->watches) == 0);
176      assert(IsClosing(client_p) && IsDead(client_p));
177  
178      MyFree(client_p->localClient->response);
# Line 182 | Line 185 | free_client(struct Client *client_p)
185      {
186        assert(0 < client_p->localClient->listener->ref_count);
187        if (0 == --client_p->localClient->listener->ref_count &&
188 <          !client_p->localClient->listener->active)
188 >          !client_p->localClient->listener->active)
189          free_listener(client_p->localClient->listener);
190      }
191  
# Line 201 | Line 204 | free_client(struct Client *client_p)
204   *
205   * inputs       - NOT USED (from event)
206   * output       - next time_t when check_pings() should be called again
207 < * side effects -
207 > * side effects -
208   *
209   *
210   * A PING can be sent to clients as necessary.
# Line 223 | Line 226 | free_client(struct Client *client_p)
226  
227   static void
228   check_pings(void *notused)
229 < {              
229 > {
230    check_pings_list(&local_client_list);
231    check_pings_list(&serv_list);
232    check_unknowns_list();
# Line 233 | Line 236 | check_pings(void *notused)
236   *
237   * inputs       - pointer to list to check
238   * output       - NONE
239 < * side effects -
239 > * side effects -
240   */
241   static void
242   check_pings_list(dlink_list *list)
243   {
244 <  char scratch[32];        /* way too generous but... */
244 >  char scratch[IRCD_BUFSIZE];
245    int ping = 0;      /* ping time value from client */
246    dlink_node *ptr = NULL, *next_ptr = NULL;
247  
# Line 253 | Line 256 | check_pings_list(dlink_list *list)
256      if (IsDead(client_p))
257      {
258        /* Ignore it, its been exited already */
259 <      continue;
259 >      continue;
260      }
261  
262      if (!IsRegistered(client_p))
# Line 265 | Line 268 | check_pings_list(dlink_list *list)
268      {
269        if (!IsPingSent(client_p))
270        {
271 <        /*
272 <         * if we havent PINGed the connection and we havent
273 <         * heard from it in a while, PING it to make sure
274 <         * it is still alive.
275 <         */
276 <        SetPingSent(client_p);
277 <        client_p->localClient->lasttime = CurrentTime - ping;
278 <        sendto_one(client_p, "PING :%s", ID_or_name(&me, client_p));
271 >        /*
272 >         * if we havent PINGed the connection and we havent
273 >         * heard from it in a while, PING it to make sure
274 >         * it is still alive.
275 >         */
276 >        SetPingSent(client_p);
277 >        client_p->localClient->lasttime = CurrentTime - ping;
278 >        sendto_one(client_p, "PING :%s", ID_or_name(&me, client_p));
279        }
280        else
281        {
# Line 283 | Line 286 | check_pings_list(dlink_list *list)
286             * and it has a ping time, then close its connection.
287             */
288            if (IsServer(client_p) || IsHandshake(client_p))
289 <          {
290 <            sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
291 <                                 "No response from %s, closing link",
292 <                                 get_client_name(client_p, HIDE_IP));
293 <            sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
294 <                                 "No response from %s, closing link",
295 <                                 get_client_name(client_p, MASK_IP));
296 <            ilog(LOG_TYPE_IRCD, "No response from %s, closing link",
297 <                 get_client_name(client_p, HIDE_IP));
298 <          }
289 >          {
290 >            sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
291 >                                 "No response from %s, closing link",
292 >                                 get_client_name(client_p, HIDE_IP));
293 >            sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
294 >                                 "No response from %s, closing link",
295 >                                 get_client_name(client_p, MASK_IP));
296 >            ilog(LOG_TYPE_IRCD, "No response from %s, closing link",
297 >                 get_client_name(client_p, HIDE_IP));
298 >          }
299  
300            snprintf(scratch, sizeof(scratch), "Ping timeout: %d seconds",
301                     (int)(CurrentTime - client_p->localClient->lasttime));
302 <          exit_client(client_p, &me, scratch);
302 >          exit_client(client_p, scratch);
303          }
304        }
305      }
# Line 323 | Line 326 | check_unknowns_list(void)
326       * for > 30s, close them.
327       */
328      if (IsAuthFinished(client_p) && (CurrentTime - client_p->localClient->firsttime) > 30)
329 <      exit_client(client_p, &me, "Registration timed out");
329 >      exit_client(client_p, "Registration timed out");
330    }
331   }
332  
# Line 334 | Line 337 | check_unknowns_list(void)
337   * side effects - Check all connections for a pending kline against the
338   *                client, exit the client if a kline matches.
339   */
340 < void
340 > void
341   check_conf_klines(void)
342 < {              
342 > {
343    struct Client *client_p = NULL;       /* current local client_p being examined */
344    struct MaskItem *conf = NULL;
345    dlink_node *ptr, *next_ptr;
# Line 354 | Line 357 | check_conf_klines(void)
357                                    client_p->localClient->aftype)) != NULL)
358      {
359        if (conf->type == CONF_EXEMPT)
360 <        continue;
360 >        continue;
361  
362 <      ban_them(client_p, conf);
362 >      conf_try_ban(client_p, conf);
363        continue; /* and go examine next fd/client_p */
364      }
365  
366 <    if (ConfigFileEntry.glines && (conf = find_gline(client_p)))
366 >    if (ConfigFileEntry.glines)
367      {
368 <      if (IsExemptKline(client_p) ||
369 <          IsExemptGline(client_p))
368 >      if ((conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
369 >                                       CONF_GLINE, client_p->localClient->aftype,
370 >                                       client_p->username, NULL, 1)))
371        {
372 <        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
373 <                             "GLINE over-ruled for %s, client is %sline_exempt",
370 <                             get_client_name(client_p, HIDE_IP), IsExemptKline(client_p) ? "k" : "g");
372 >        conf_try_ban(client_p, conf);
373 >        /* and go examine next fd/client_p */
374          continue;
375        }
376 +    }
377  
378 <      ban_them(client_p, conf);
379 <      /* and go examine next fd/client_p */    
380 <      continue;
377 <    }
378 <
379 <    if ((conf = find_kill(client_p)) != NULL)
378 >    if ((conf = find_conf_by_address(client_p->host, &client_p->localClient->ip,
379 >                                     CONF_KLINE, client_p->localClient->aftype,
380 >                                     client_p->username, NULL, 1)))
381      {
382 <      if (IsExemptKline(client_p))
383 <      {
383 <        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
384 <                             "KLINE over-ruled for %s, client is kline_exempt",
385 <                             get_client_name(client_p, HIDE_IP));
386 <        continue;
387 <      }
388 <
389 <      ban_them(client_p, conf);
390 <      continue;
382 >      conf_try_ban(client_p, conf);
383 >      continue;
384      }
385  
386      if ((conf = find_matching_name_conf(CONF_XLINE,  client_p->info,
387 <                                        NULL, NULL, 0)) != NULL ||
395 <        (conf = find_matching_name_conf(CONF_RXLINE, client_p->info,
396 <                                        NULL, NULL, 0)) != NULL)
387 >                                        NULL, NULL, 0)))
388      {
389 <      ban_them(client_p, conf);
389 >      conf_try_ban(client_p, conf);
390        continue;
391      }
392    }
# Line 411 | Line 402 | check_conf_klines(void)
402        if (conf->type == CONF_EXEMPT)
403          continue;
404  
405 <      exit_client(client_p, &me, "D-lined");
405 >      exit_client(client_p, "D-lined");
406      }
407    }
408   }
409  
410   /*
411 < * ban_them
411 > * conf_try_ban
412   *
413   * inputs       - pointer to client to ban
414   *              - pointer to MaskItem
415   * output       - NONE
416   * side effects - given client_p is banned
417   */
418 < static void
419 < ban_them(struct Client *client_p, struct MaskItem *conf)
418 > void
419 > conf_try_ban(struct Client *client_p, struct MaskItem *conf)
420   {
421 <  const char *user_reason = NULL;       /* What is sent to user */
421 >  const char *user_reason = NULL;  /* What is sent to user */
422    const char *type_string = NULL;
423    const char dline_string[] = "D-line";
424    const char kline_string[] = "K-line";
# Line 436 | Line 427 | ban_them(struct Client *client_p, struct
427  
428    switch (conf->type)
429    {
439    case CONF_RKLINE:
430      case CONF_KLINE:
431 +      if (IsExemptKline(client_p))
432 +      {
433 +        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
434 +                             "KLINE over-ruled for %s, client is kline_exempt",
435 +                             get_client_name(client_p, HIDE_IP));
436 +        return;
437 +      }
438 +
439        type_string = kline_string;
440        break;
441      case CONF_DLINE:
442        type_string = dline_string;
443        break;
444      case CONF_GLINE:
445 +      if (IsExemptKline(client_p) ||
446 +          IsExemptGline(client_p))
447 +      {
448 +        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
449 +                             "GLINE over-ruled for %s, client is %sline_exempt",
450 +                             get_client_name(client_p, HIDE_IP), IsExemptKline(client_p) ? "k" : "g");
451 +        return;
452 +      }
453 +
454        type_string = gline_string;
455        break;
449    case CONF_RXLINE:
456      case CONF_XLINE:
457        type_string = xline_string;
458        ++conf->count;
# Line 462 | Line 468 | ban_them(struct Client *client_p, struct
468                         type_string, get_client_name(client_p, HIDE_IP));
469  
470    if (IsClient(client_p))
471 <    sendto_one(client_p, form_str(ERR_YOUREBANNEDCREEP),
466 <               me.name, client_p->name, user_reason);
471 >    sendto_one_numeric(client_p, &me, ERR_YOUREBANNEDCREEP, user_reason);
472  
473 <  exit_client(client_p, &me, user_reason);
473 >  exit_client(client_p, user_reason);
474   }
475  
476   /* update_client_exit_stats()
477   *
478   * input        - pointer to client
479   * output       - NONE
480 < * side effects -
480 > * side effects -
481   */
482   static void
483   update_client_exit_stats(struct Client *client_p)
# Line 502 | Line 507 | update_client_exit_stats(struct Client *
507   * side effects - find person by (nick)name
508   */
509   struct Client *
510 < find_person(const struct Client *client_p, const char *name)
510 > find_person(const struct Client *const source_p, const char *name)
511   {
512 <  struct Client *c2ptr = NULL;
512 >  struct Client *target_p = NULL;
513  
514    if (IsDigit(*name))
515    {
516 <    if ((c2ptr = hash_find_id(name)) != NULL)
517 <    {
513 <      /* invisible users shall not be found by UID guessing */
514 <      if (HasUMode(c2ptr, UMODE_INVISIBLE))
515 <        if (!IsServer(client_p) && !HasFlag(client_p, FLAGS_SERVICE))
516 <          c2ptr = NULL;
517 <    }
516 >    if (IsServer(source_p->from))
517 >      target_p = hash_find_id(name);
518    }
519    else
520 <    c2ptr = hash_find_client(name);
520 >    target_p = hash_find_client(name);
521  
522 <  return ((c2ptr != NULL && IsClient(c2ptr)) ? c2ptr : NULL);
522 >  return (target_p && IsClient(target_p)) ? target_p : NULL;
523   }
524  
525   /*
526 < * find_chasing - find the client structure for a nick name (user)
527 < *      using history mechanism if necessary. If the client is not found,
528 < *      an error message (NO SUCH NICK) is generated. If the client was found
529 < *      through the history, chasing will be 1 and otherwise 0.
526 > * find_chasing - find the client structure for a nick name (name)
527 > *      using history mechanism if necessary. If the client is not found,
528 > *      an error message (NO SUCH NICK) is generated.
529   */
530   struct Client *
531 < find_chasing(struct Client *client_p, struct Client *source_p, const char *user, int *chasing)
531 > find_chasing(struct Client *source_p, const char *name)
532   {
533 <  struct Client *who = find_person(client_p, user);
535 <
536 <  if (chasing)
537 <    *chasing = 0;
533 >  struct Client *who = find_person(source_p, name);
534  
535    if (who)
536      return who;
537  
538 <  if (IsDigit(*user))
538 >  if (IsDigit(*name))
539      return NULL;
540  
541 <  if ((who = get_history(user,
542 <                        (time_t)ConfigFileEntry.kill_chase_time_limit))
543 <                         == NULL)
541 >  if ((who = whowas_get_history(name,
542 >                         (time_t)ConfigFileEntry.kill_chase_time_limit))
543 >                         == NULL)
544    {
545 <    sendto_one(source_p, form_str(ERR_NOSUCHNICK),
550 <               me.name, source_p->name, user);
545 >    sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, name);
546      return NULL;
547    }
548  
554  if (chasing)
555    *chasing = 1;
556
549    return who;
550   }
551  
# Line 582 | Line 574 | get_client_name(const struct Client *cli
574  
575    assert(client != NULL);
576  
577 <  if (!MyConnect(client))
577 >  if (!MyConnect(client))
578      return client->name;
579  
580    if (IsServer(client) || IsConnecting(client) || IsHandshake(client))
# Line 626 | Line 618 | void
618   free_exited_clients(void)
619   {
620    dlink_node *ptr = NULL, *next = NULL;
621 <  
621 >
622    DLINK_FOREACH_SAFE(ptr, next, dead_list.head)
623    {
624      free_client(ptr->data);
# Line 650 | Line 642 | exit_one_client(struct Client *source_p,
642  
643    if (IsClient(source_p))
644    {
645 <    if (source_p->servptr->serv != NULL)
654 <      dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list);
645 >    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list);
646  
647      /*
648       * If a person is on a channel, send a QUIT notice
# Line 665 | Line 656 | exit_one_client(struct Client *source_p,
656      DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head)
657        remove_user_from_channel(lp->data);
658  
659 <    add_history(source_p, 0);
660 <    off_history(source_p);
659 >    whowas_add_history(source_p, 0);
660 >    whowas_off_history(source_p);
661  
662      watch_check_hash(source_p, RPL_LOGOFF);
663  
# Line 688 | Line 679 | exit_one_client(struct Client *source_p,
679    }
680  
681    /* Remove source_p from the client lists */
682 <  if (HasID(source_p))
682 >  if (source_p->id[0])
683      hash_del_id(source_p);
684    if (source_p->name[0])
685      hash_del_client(source_p);
# Line 700 | Line 691 | exit_one_client(struct Client *source_p,
691     * NOTE: source_p->node.next cannot be NULL if the client is added
692     *       to global_client_list (there is always &me at its end)
693     */
694 <  if (source_p != NULL && source_p->node.next != NULL)
694 >  if (source_p->node.next != NULL) /* XXX: not needed? */
695      dlinkDelete(&source_p->node, &global_client_list);
696  
697    update_client_exit_stats(source_p);
# Line 713 | Line 704 | exit_one_client(struct Client *source_p,
704    dlinkAdd(source_p, make_dlink_node(), &dead_list);
705   }
706  
707 < /* Recursively send QUITs and SQUITs for source_p and all its dependent clients
717 < * and servers to those servers that need them.  A server needs the client
718 < * QUITs if it can't figure them out from the SQUIT (ie pre-TS4) or if it
719 < * isn't getting the SQUIT because of @#(*&@)# hostmasking.  With TS4, once
720 < * a link gets a SQUIT, it doesn't need any QUIT/SQUITs for clients depending
721 < * on that one -orabidoo
722 < *
723 < * This is now called on each local server -adx
724 < */
725 < static void
726 < recurse_send_quits(struct Client *original_source_p, struct Client *source_p,
727 <                   struct Client *from, struct Client *to, const char *comment,
728 <                   const char *splitstr)
729 < {
730 <  dlink_node *ptr, *next;
731 <  struct Client *target_p;
732 <
733 <  assert(to != source_p);  /* should be already removed from serv_list */
734 <
735 <  /* If this server can handle quit storm (QS) removal
736 <   * of dependents, just send the SQUIT
737 <   */
738 <  if (!IsCapable(to, CAP_QS))
739 <    DLINK_FOREACH_SAFE(ptr, next, source_p->serv->client_list.head)
740 <    {
741 <      target_p = ptr->data;
742 <      sendto_one(to, ":%s QUIT :%s", target_p->name, splitstr);
743 <    }
744 <
745 <  DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head)
746 <    recurse_send_quits(original_source_p, ptr->data, from, to,
747 <                       comment, splitstr);
748 <
749 <  if ((source_p == original_source_p && to != from) ||
750 <                  !IsCapable(to, CAP_QS))
751 <  {
752 <    /* don't use a prefix here - we have to be 100% sure the message
753 <     * will be accepted without Unknown prefix etc.. */
754 <    sendto_one(to, "SQUIT %s :%s", ID_or_name(source_p, to), comment);
755 <  }
756 < }
757 <
758 < /*
707 > /*
708   * Remove all clients that depend on source_p; assumes all (S)QUITs have
709 < * already been sent.  we make sure to exit a server's dependent clients
710 < * and servers before the server itself; exit_one_client takes care of
709 > * already been sent.  we make sure to exit a server's dependent clients
710 > * and servers before the server itself; exit_one_client takes care of
711   * actually removing things off llists.   tweaked from +CSr31  -orabidoo
712   */
713   static void
# Line 777 | Line 726 | recurse_remove_clients(struct Client *so
726   }
727  
728   /*
780 ** Remove *everything* that depends on source_p, from all lists, and sending
781 ** all necessary QUITs and SQUITs.  source_p itself is still on the lists,
782 ** and its SQUITs have been sent except for the upstream one  -orabidoo
783 */
784 static void
785 remove_dependents(struct Client *source_p, struct Client *from,
786                  const char *comment, const char *splitstr)
787 {
788  dlink_node *ptr = NULL;
789
790  DLINK_FOREACH(ptr, serv_list.head)
791    recurse_send_quits(source_p, source_p, from, ptr->data,
792                       comment, splitstr);
793
794  recurse_remove_clients(source_p, splitstr);
795 }
796
797 /*
729   * exit_client - exit a client of any type. Generally, you can use
730   * this on any struct Client, regardless of its state.
731   *
732   * Note, you shouldn't exit remote _users_ without first doing
733   * AddFlag(x, FLAGS_KILLED) and propagating a kill or similar message.
734 + *
735   * However, it is perfectly correct to call exit_client to force a _server_
736   * quit (either local or remote one).
737   *
738 + *
739   * inputs:       - a client pointer that is going to be exited
807 *               - for servers, the second argument is a pointer to who
808 *                 is firing the server. This side won't get any generated
809 *                 messages. NEVER NULL!
740   * output:       none
741   * side effects: the client is delinked from all lists, disconnected,
742   *               and the rest of IRC network is notified of the exit.
743   *               Client memory is scheduled to be freed
744   */
745   void
746 < exit_client(struct Client *source_p, struct Client *from, const char *comment)
746 > exit_client(struct Client *source_p, const char *comment)
747   {
748    dlink_node *m = NULL;
749 +  /* Store the direction to source_p, close_connection sets it to NULL */
750 +  struct Client *client_p = source_p->from;
751  
752    if (MyConnect(source_p))
753    {
# Line 830 | Line 762 | exit_client(struct Client *source_p, str
762      if (IsIpHash(source_p))
763        remove_one_ip(&source_p->localClient->ip);
764  
765 <    if (source_p->localClient->auth)
834 <    {
835 <      delete_auth(source_p->localClient->auth);
836 <      source_p->localClient->auth = NULL;
837 <    }
765 >    delete_auth(&source_p->localClient->auth);
766  
767      /*
768       * This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING
# Line 871 | Line 799 | exit_client(struct Client *source_p, str
799                             source_p->name, source_p->username, source_p->host, comment,
800                             ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
801                             "255.255.255.255" : source_p->sockhost);
874      sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, SEND_NOTICE,
875                           "CLIEXIT: %s %s %s %s 0 %s",
876                           source_p->name,
877                           source_p->username,
878                           source_p->host,
879                           ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
880                           "255.255.255.255" : source_p->sockhost,
881                           comment);
802        ilog(LOG_TYPE_USER, "%s (%3u:%02u:%02u): %s!%s@%s %llu/%llu",
803             myctime(source_p->localClient->firsttime), (unsigned int)(on_for / 3600),
804             (unsigned int)((on_for % 3600)/60), (unsigned int)(on_for % 60),
# Line 893 | Line 813 | exit_client(struct Client *source_p, str
813  
814        assert(dlinkFind(&serv_list, source_p));
815        dlinkDelete(&source_p->localClient->lclient_node, &serv_list);
896      unset_chcap_usage_counts(source_p);
816      }
817  
818      if (!IsDead(source_p))
819      {
820        if (IsServer(source_p))
821        {
822 <        /* for them, we are exiting the network */
823 <        sendto_one(source_p, ":%s SQUIT %s :%s",
824 <                   ID_or_name(from, source_p), me.name, comment);
822 >        if (!HasFlag(source_p, FLAGS_SQUIT))
823 >        {
824 >          /* for them, we are exiting the network */
825 >          sendto_one(source_p, ":%s SQUIT %s :%s",
826 >                     me.id, me.id, comment);
827 >        }
828        }
829  
830        sendto_one(source_p, "ERROR :Closing Link: %s (%s)",
# Line 922 | Line 844 | exit_client(struct Client *source_p, str
844      */
845      close_connection(source_p);
846    }
847 +  else if (IsClient(source_p) && HasFlag(source_p->servptr, FLAGS_EOB))
848 +    sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE,
849 +                         "Client exiting at %s: %s (%s@%s) [%s]",
850 +                         source_p->servptr->name, source_p->name,
851 +                         source_p->username, source_p->host, comment);
852  
853    if (IsServer(source_p))
854    {
855 <    char splitstr[HOSTLEN + HOSTLEN + 2];
855 >    char splitstr[HOSTLEN + HOSTLEN + 2] = "";
856  
857      /* This shouldn't ever happen */
858      assert(source_p->serv != NULL && source_p->servptr != NULL);
859  
860      if (ConfigServerHide.hide_servers)
861        /*
862 <       * Set netsplit message to "*.net *.split" to still show
862 >       * Set netsplit message to "*.net *.split" to still show
863         * that its a split, but hide the servers splitting
864         */
865 <      strcpy(splitstr, "*.net *.split");
865 >      strlcpy(splitstr, "*.net *.split", sizeof(splitstr));
866      else
867        snprintf(splitstr, sizeof(splitstr), "%s %s",
868                 source_p->servptr->name, source_p->name);
869  
870 <    remove_dependents(source_p, from->from, comment, splitstr);
870 >    /* Send SQUIT for source_p in every direction. source_p is already off of serv_list here */
871 >    if (!HasFlag(source_p, FLAGS_SQUIT))
872 >      sendto_server(NULL, NOCAPS, NOCAPS, "SQUIT %s :%s", source_p->id, comment);
873 >
874 >    /* Now exit the clients internally */
875 >    recurse_remove_clients(source_p, splitstr);
876  
877      if (source_p->servptr == &me)
878      {
# Line 950 | Line 882 | exit_client(struct Client *source_p, str
882                             source_p->localClient->send.bytes >> 10,
883                             source_p->localClient->recv.bytes >> 10);
884        ilog(LOG_TYPE_IRCD, "%s was connected for %d seconds.  %llu/%llu sendK/recvK.",
885 <           source_p->name, (int)(CurrentTime - source_p->localClient->firsttime),
885 >           source_p->name, (int)(CurrentTime - source_p->localClient->firsttime),
886             source_p->localClient->send.bytes >> 10,
887             source_p->localClient->recv.bytes >> 10);
888      }
889    }
890    else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED))
891 <  {
892 <    sendto_server(from->from, CAP_TS6, NOCAPS,
961 <                  ":%s QUIT :%s", ID(source_p), comment);
962 <    sendto_server(from->from, NOCAPS, CAP_TS6,
963 <                  ":%s QUIT :%s", source_p->name, comment);
964 <  }
891 >    sendto_server(client_p, NOCAPS, NOCAPS, ":%s QUIT :%s",
892 >                  source_p->id, comment);
893  
894    /* The client *better* be off all of the lists */
895    assert(dlinkFind(&unknown_list, source_p) == NULL);
# Line 1005 | Line 933 | dead_link_on_write(struct Client *client
933   void
934   dead_link_on_read(struct Client *client_p, int error)
935   {
936 <  char errmsg[255];
936 >  char errmsg[IRCD_BUFSIZE];
937    int current_error;
938  
939    if (IsDefunct(client_p))
# Line 1019 | Line 947 | dead_link_on_read(struct Client *client_
947    if (IsServer(client_p) || IsHandshake(client_p))
948    {
949      int connected = CurrentTime - client_p->localClient->firsttime;
950 <      
950 >
951      if (error == 0)
952      {
953        /* Admins get the real IP */
954        sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
955 <                           "Server %s closed the connection",
956 <                           get_client_name(client_p, SHOW_IP));
955 >                           "Server %s closed the connection",
956 >                           get_client_name(client_p, SHOW_IP));
957  
958        /* Opers get a masked IP */
959        sendto_realops_flags(UMODE_ALL, L_OPER, SEND_NOTICE,
960 <                           "Server %s closed the connection",
961 <                           get_client_name(client_p, MASK_IP));
960 >                           "Server %s closed the connection",
961 >                           get_client_name(client_p, MASK_IP));
962  
963        ilog(LOG_TYPE_IRCD, "Server %s closed the connection",
964 <           get_client_name(client_p, SHOW_IP));
964 >           get_client_name(client_p, SHOW_IP));
965      }
966      else
967      {
968        report_error(L_ADMIN, "Lost connection to %s: %s",
969 <                   get_client_name(client_p, SHOW_IP), current_error);
969 >                   get_client_name(client_p, SHOW_IP), current_error);
970        report_error(L_OPER, "Lost connection to %s: %s",
971 <                   get_client_name(client_p, MASK_IP), current_error);
971 >                   get_client_name(client_p, MASK_IP), current_error);
972      }
973  
974      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
975 <                         "%s had been connected for %d day%s, %2d:%02d:%02d",
976 <                         client_p->name, connected/86400,
977 <                         (connected/86400 == 1) ? "" : "s",
978 <                         (connected % 86400) / 3600, (connected % 3600) / 60,
979 <                         connected % 60);
975 >                         "%s had been connected for %d day%s, %2d:%02d:%02d",
976 >                         client_p->name, connected/86400,
977 >                         (connected/86400 == 1) ? "" : "s",
978 >                         (connected % 86400) / 3600, (connected % 3600) / 60,
979 >                         connected % 60);
980    }
981  
982    if (error == 0)
# Line 1058 | Line 986 | dead_link_on_read(struct Client *client_
986      snprintf(errmsg, sizeof(errmsg), "Read error: %s",
987               strerror(current_error));
988  
989 <  exit_client(client_p, &me, errmsg);
989 >  exit_client(client_p, errmsg);
990   }
991  
992   void
# Line 1089 | Line 1017 | exit_aborted_clients(void)
1017      else
1018        notice = "Write error: connection closed";
1019  
1020 <    exit_client(target_p, &me, notice);  
1020 >    exit_client(target_p, notice);
1021      free_dlink_node(ptr);
1022    }
1023   }
# Line 1117 | Line 1045 | del_accept(struct split_nuh_item *accept
1045  
1046   struct split_nuh_item *
1047   find_accept(const char *nick, const char *user,
1048 <            const char *host, struct Client *client_p, int do_match)
1048 >            const char *host, struct Client *client_p,
1049 >            int (*cmpfunc)(const char *, const char *))
1050   {
1051    dlink_node *ptr = NULL;
1123  /* XXX We wouldn't need that if match() would return 0 on match */
1124  int (*cmpfunc)(const char *, const char *) = do_match ? match : irccmp;
1052  
1053    DLINK_FOREACH(ptr, client_p->localClient->acceptlist.head)
1054    {
# Line 1150 | Line 1077 | accept_message(struct Client *source,
1077    dlink_node *ptr = NULL;
1078  
1079    if (source == target || find_accept(source->name, source->username,
1080 <                                      source->host, target, 1))
1080 >                                      source->host, target, match))
1081      return 1;
1082  
1083    if (HasUMode(target, UMODE_SOFTCALLERID))
# Line 1182 | Line 1109 | idle_time_get(const struct Client *sourc
1109    unsigned int idle = 0;
1110    unsigned int min_idle = 0;
1111    unsigned int max_idle = 0;
1112 <  struct ClassItem *class = get_class_ptr(&target_p->localClient->confs);
1112 >  const struct ClassItem *class = get_class_ptr(&target_p->localClient->confs);
1113  
1114    if (!(class->flags & CLASS_FLAGS_FAKE_IDLE) || target_p == source_p)
1115      return CurrentTime - target_p->localClient->last_privmsg;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)