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 6513 by michael, Sun Sep 6 18:32:38 2015 UTC vs.
Revision 8385 by michael, Fri Mar 16 20:09:55 2018 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2015 ircd-hybrid development team
4 > *  Copyright (c) 1997-2018 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 35 | Line 35
35   #include "auth.h"
36   #include "s_bsd.h"
37   #include "conf.h"
38 + #include "conf_gecos.h"
39   #include "log.h"
40   #include "misc.h"
41   #include "server.h"
# Line 42 | Line 43
43   #include "whowas.h"
44   #include "user.h"
45   #include "memory.h"
45 #include "mempool.h"
46   #include "hostmask.h"
47   #include "listener.h"
48   #include "userhost.h"
# Line 60 | Line 60 | dlink_list global_client_list;
60   dlink_list global_server_list;
61   dlink_list oper_list;
62  
63 static mp_pool_t *client_pool, *connection_pool;
63   static dlink_list dead_list, abort_list;
64   static dlink_node *eac_next;  /* next aborted client to exit */
65  
# Line 81 | Line 80 | static dlink_node *eac_next;  /* next ab
80   *                      'from'). ('from' is a local client!!).
81   */
82   struct Client *
83 < make_client(struct Client *from)
83 > client_make(struct Client *from)
84   {
85 <  struct Client *const client_p = mp_pool_get(client_pool);
85 >  struct Client *const client_p = xcalloc(sizeof(*client_p));
86  
87 <  if (!from)
87 >  if (from)
88 >    client_p->from = from;
89 >  else
90    {
91      client_p->from = client_p;  /* 'from' of local client is self! */
92 <    client_p->connection = mp_pool_get(connection_pool);
92 >    client_p->connection = xcalloc(sizeof(*client_p->connection));
93      client_p->connection->since = CurrentTime;
94      client_p->connection->lasttime = CurrentTime;
95      client_p->connection->firsttime = CurrentTime;
# Line 97 | Line 98 | make_client(struct Client *from)
98      /* as good a place as any... */
99      dlinkAdd(client_p, &client_p->connection->lclient_node, &unknown_list);
100    }
100  else
101    client_p->from = from;
101  
102    client_p->idhnext = client_p;
103    client_p->hnext = client_p;
# Line 110 | Line 109 | make_client(struct Client *from)
109   }
110  
111   /*
112 < * free_client
112 > * client_free
113   *
114   * inputs       - pointer to client
115   * output       - NONE
116   * side effects - client pointed to has its memory freed
117   */
118   static void
119 < free_client(struct Client *client_p)
119 > client_free(struct Client *client_p)
120   {
121 +  assert(!IsMe(client_p));
122    assert(client_p != &me);
123    assert(client_p->hnext == client_p);
124    assert(client_p->idhnext == client_p);
125 <  assert(client_p->channel.head == NULL);
125 >
126 >  assert(client_p->node.data == NULL);
127 >  assert(client_p->node.prev == NULL);
128 >  assert(client_p->node.next == NULL);
129 >
130 >  assert(client_p->lnode.data == NULL);
131 >  assert(client_p->lnode.prev == NULL);
132 >  assert(client_p->lnode.next == NULL);
133 >
134 >  assert(dlink_list_length(&client_p->whowas_list) == 0);
135 >  assert(client_p->whowas_list.head == NULL);
136 >  assert(client_p->whowas_list.tail == NULL);
137 >
138    assert(dlink_list_length(&client_p->channel) == 0);
139 <  assert(dlink_list_length(&client_p->whowas) == 0);
139 >  assert(client_p->channel.head == NULL);
140 >  assert(client_p->channel.tail == NULL);
141 >
142    assert(dlink_list_length(&client_p->svstags) == 0);
143 +  assert(client_p->svstags.head == NULL);
144 +  assert(client_p->svstags.tail == NULL);
145 +
146  
147 <  MyFree(client_p->serv);
148 <  MyFree(client_p->certfp);
147 >  xfree(client_p->serv);
148 >  xfree(client_p->certfp);
149  
150    if (MyConnect(client_p))
151    {
152 <    assert(client_p->connection->invited.head == NULL);
153 <    assert(dlink_list_length(&client_p->connection->invited) == 0);
152 >    assert(client_p->connection->lclient_node.data == NULL);
153 >    assert(client_p->connection->lclient_node.prev == NULL);
154 >    assert(client_p->connection->lclient_node.next == NULL);
155 >
156 >    assert(client_p->connection->list_task == NULL);
157 >    assert(client_p->connection->auth == NULL);
158 >
159 >    assert(dlink_list_length(&client_p->connection->acceptlist) == 0);
160 >    assert(client_p->connection->acceptlist.head == NULL);
161 >    assert(client_p->connection->acceptlist.tail == NULL);
162 >
163 >
164      assert(dlink_list_length(&client_p->connection->watches) == 0);
165 <    assert(HasFlag(client_p, FLAGS_CLOSING) && IsDead(client_p));
165 >    assert(client_p->connection->watches.head == NULL);
166 >    assert(client_p->connection->watches.tail == NULL);
167  
168 <    MyFree(client_p->connection->challenge_response);
169 <    client_p->connection->challenge_response = NULL;
170 <    MyFree(client_p->connection->challenge_operator);
171 <    client_p->connection->challenge_operator = NULL;
168 >    assert(dlink_list_length(&client_p->connection->confs) == 0);
169 >    assert(client_p->connection->confs.head == NULL);
170 >    assert(client_p->connection->confs.tail == NULL);
171 >
172 >    assert(dlink_list_length(&client_p->connection->invited) == 0);
173 >    assert(client_p->connection->invited.head == NULL);
174 >    assert(client_p->connection->invited.tail == NULL);
175 >
176 >    assert(client_p->connection->fd == NULL);
177 >
178 >    assert(HasFlag(client_p, FLAGS_CLOSING) && IsDead(client_p));
179  
180      /*
181       * Clean up extra sockets from listen {} blocks which have been discarded.
# Line 154 | Line 189 | free_client(struct Client *client_p)
189      dbuf_clear(&client_p->connection->buf_recvq);
190      dbuf_clear(&client_p->connection->buf_sendq);
191  
192 <    mp_pool_release(client_p->connection);
192 >    xfree(client_p->connection);
193 >    client_p->connection = NULL;
194    }
195  
196 <  mp_pool_release(client_p);
196 >  xfree(client_p);
197 > }
198 >
199 > static void
200 > svstag_free(struct ServicesTag *svstag, dlink_list *list)
201 > {
202 >  dlinkDelete(&svstag->node, list);
203 >  xfree(svstag->tag);
204 >  xfree(svstag);
205 > }
206 >
207 > void
208 > client_detach_svstag(dlink_list *list, unsigned int numeric)
209 > {
210 >  dlink_node *node, *node_next;
211 >
212 >  DLINK_FOREACH_SAFE(node, node_next, list->head)
213 >  {
214 >    struct ServicesTag *svstag = node->data;
215 >
216 >    if (svstag->numeric == numeric)
217 >      svstag_free(svstag, list);
218 >  }
219   }
220  
221   void
222 < client_attach_svstag(struct Client *client_p, unsigned int numeric,
223 <                     const char *umodes, const char *const tag)
222 > client_attach_svstag(dlink_list *list, unsigned int numeric,
223 >                     const char *umodes, const char *tag)
224   {
167  struct ServicesTag *svstag = NULL;
225    const struct user_modes *tab = NULL;
226  
227    if (numeric >= ERR_LAST_ERR_MSG || *umodes != '+')
228      return;
229  
230 <  svstag = MyCalloc(sizeof(*svstag));
230 >  struct ServicesTag *svstag = xcalloc(sizeof(*svstag));
231    svstag->numeric = numeric;
232    svstag->tag = xstrdup(tag);
233  
# Line 179 | Line 236 | client_attach_svstag(struct Client *clie
236        svstag->umodes |= tab->flag;
237  
238    if (numeric != RPL_WHOISOPERATOR)
239 <    dlinkAddTail(svstag, &svstag->node, &client_p->svstags);
239 >    dlinkAddTail(svstag, &svstag->node, list);
240    else
241 <    dlinkAdd(svstag, &svstag->node, &client_p->svstags);
241 >    dlinkAdd(svstag, &svstag->node, list);
242   }
243  
244   void
245 < client_clear_svstags(struct Client *client_p)
245 > client_clear_svstags(dlink_list *list)
246   {
247 <  dlink_node *node = NULL, *node_next = NULL;
248 <
192 <  DLINK_FOREACH_SAFE(node, node_next, client_p->svstags.head)
193 <  {
194 <    struct ServicesTag *svstag = node->data;
195 <
196 <    dlinkDelete(&svstag->node, &client_p->svstags);
197 <    MyFree(svstag->tag);
198 <    MyFree(svstag);
199 <  }
247 >  while (list->head)
248 >    svstag_free(list->head->data, list);
249   }
250  
251   /* check_pings_list()
# Line 208 | Line 257 | client_clear_svstags(struct Client *clie
257   static void
258   check_pings_list(dlink_list *list)
259   {
260 <  char buf[IRCD_BUFSIZE] = "";
261 <  int ping = 0;      /* ping time value from client */
260 >  char buf[32] = "";  /* 32 = sizeof("Ping timeout: 999999999 seconds") */
261 >  unsigned int ping = 0;      /* ping time value from client */
262    dlink_node *node = NULL, *node_next = NULL;
263  
264    DLINK_FOREACH_SAFE(node, node_next, list->head)
# Line 249 | Line 298 | check_pings_list(dlink_list *list)
298            {
299              sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
300                                   "No response from %s, closing link",
301 <                                 get_client_name(client_p, SHOW_IP));
301 >                                 client_get_name(client_p, SHOW_IP));
302              sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
303                                   "No response from %s, closing link",
304 <                                 get_client_name(client_p, MASK_IP));
304 >                                 client_get_name(client_p, MASK_IP));
305              ilog(LOG_TYPE_IRCD, "No response from %s, closing link",
306 <                 get_client_name(client_p, SHOW_IP));
306 >                 client_get_name(client_p, SHOW_IP));
307            }
308  
309 <          snprintf(buf, sizeof(buf), "Ping timeout: %d seconds",
310 <                   (int)(CurrentTime - client_p->connection->lasttime));
309 >          snprintf(buf, sizeof(buf), "Ping timeout: %ji seconds",
310 >                   (CurrentTime - client_p->connection->lasttime));
311            exit_client(client_p, buf);
312          }
313        }
# Line 295 | Line 344 | check_unknowns_list(void)
344   * kill off stuff that should die
345   *
346   * inputs       - NOT USED (from event)
298 * output       - next time_t when check_pings() should be called again
347   * side effects -
348   *
349   *
# Line 334 | Line 382 | check_pings(void *unused)
382   void
383   check_conf_klines(void)
384   {
337  struct MaskItem *conf = NULL;
385    dlink_node *node = NULL, *node_next = NULL;
386 +  const void *ptr;
387  
388    DLINK_FOREACH_SAFE(node, node_next, local_client_list.head)
389    {
# Line 345 | Line 393 | check_conf_klines(void)
393      if (IsDead(client_p))
394        continue;
395  
396 <    if ((conf = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE,
397 <                                     client_p->connection->aftype, NULL, NULL, 1)))
396 >    if ((ptr = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE,
397 >                                    client_p->connection->aftype, NULL, NULL, 1)))
398      {
399 <      conf_try_ban(client_p, conf);
399 >      const struct MaskItem *conf = ptr;
400 >      conf_try_ban(client_p, CLIENT_BAN_DLINE, conf->reason);
401        continue;  /* and go examine next Client */
402      }
403  
404 <    if ((conf = find_conf_by_address(client_p->host, &client_p->connection->ip,
405 <                                     CONF_KLINE, client_p->connection->aftype,
406 <                                     client_p->username, NULL, 1)))
404 >    if ((ptr = find_conf_by_address(client_p->host, &client_p->connection->ip,
405 >                                    CONF_KLINE, client_p->connection->aftype,
406 >                                    client_p->username, NULL, 1)))
407      {
408 <      conf_try_ban(client_p, conf);
408 >      const struct MaskItem *conf = ptr;
409 >      conf_try_ban(client_p, CLIENT_BAN_KLINE, conf->reason);
410        continue;  /* and go examine next Client */
411      }
412  
413 <    if ((conf = find_matching_name_conf(CONF_XLINE, client_p->info,
364 <                                        NULL, NULL, 0)))
413 >    if ((ptr = gecos_find(client_p->info, match)))
414      {
415 <      conf_try_ban(client_p, conf);
415 >      const struct GecosItem *conf = ptr;
416 >      conf_try_ban(client_p, CLIENT_BAN_XLINE, conf->reason);
417        continue;  /* and go examine next Client */
418      }
419    }
# Line 373 | Line 423 | check_conf_klines(void)
423    {
424      struct Client *client_p = node->data;
425  
426 <    if ((conf = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE,
427 <                                     client_p->connection->aftype, NULL, NULL, 1)))
426 >    if ((ptr = find_conf_by_address(NULL, &client_p->connection->ip, CONF_DLINE,
427 >                                    client_p->connection->aftype, NULL, NULL, 1)))
428      {
429 <      conf_try_ban(client_p, conf);
429 >      const struct MaskItem *conf = ptr;
430 >      conf_try_ban(client_p, CLIENT_BAN_DLINE, conf->reason);
431        continue;  /* and go examine next Client */
432      }
433    }
# Line 391 | Line 442 | check_conf_klines(void)
442   * side effects - given client_p is banned
443   */
444   void
445 < conf_try_ban(struct Client *client_p, struct MaskItem *conf)
445 > conf_try_ban(struct Client *client_p, int type, const char *reason)
446   {
447 <  char ban_type = '\0';
447 >  char ban_type = '?';
448  
449 <  switch (conf->type)
449 >  switch (type)
450    {
451 <    case CONF_KLINE:
451 >    case CLIENT_BAN_KLINE:
452        if (HasFlag(client_p, FLAGS_EXEMPTKLINE))
453        {
454          sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
455                               "KLINE over-ruled for %s, client is kline_exempt",
456 <                             get_client_name(client_p, HIDE_IP));
456 >                             client_get_name(client_p, HIDE_IP));
457          return;
458        }
459  
460        ban_type = 'K';
461        break;
462 <    case CONF_DLINE:
462 >    case CLIENT_BAN_DLINE:
463        if (find_conf_by_address(NULL, &client_p->connection->ip, CONF_EXEMPT,
464                                 client_p->connection->aftype, NULL, NULL, 1))
465          return;
466        ban_type = 'D';
467        break;
468 <    case CONF_XLINE:
468 >    case CLIENT_BAN_XLINE:
469        if (HasFlag(client_p, FLAGS_EXEMPTXLINE))
470        {
471          sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
472                               "XLINE over-ruled for %s, client is xline_exempt",
473 <                             get_client_name(client_p, HIDE_IP));
473 >                             client_get_name(client_p, HIDE_IP));
474          return;
475        }
476  
477        ban_type = 'X';
427      ++conf->count;
478        break;
479      default:
480        assert(0);
# Line 432 | Line 482 | conf_try_ban(struct Client *client_p, st
482    }
483  
484    sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "%c-line active for %s",
485 <                       ban_type, get_client_name(client_p, HIDE_IP));
436 <
437 <  if (IsClient(client_p))
438 <    sendto_one_numeric(client_p, &me, ERR_YOUREBANNEDCREEP, conf->reason);
439 <
440 <  exit_client(client_p, conf->reason);
441 < }
485 >                       ban_type, client_get_name(client_p, HIDE_IP));
486  
443 /* update_client_exit_stats()
444 *
445 * input        - pointer to client
446 * output       - NONE
447 * side effects -
448 */
449 static void
450 update_client_exit_stats(struct Client *client_p)
451 {
487    if (IsClient(client_p))
488 <  {
454 <    assert(Count.total > 0);
488 >    sendto_one_numeric(client_p, &me, ERR_YOUREBANNEDCREEP, reason);
489  
490 <    --Count.total;
457 <    if (HasUMode(client_p, UMODE_OPER))
458 <      --Count.oper;
459 <    if (HasUMode(client_p, UMODE_INVISIBLE))
460 <      --Count.invisi;
461 <  }
462 <  else if (IsServer(client_p))
463 <    sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE,
464 <                         "Server %s split from %s",
465 <                         client_p->name, client_p->servptr->name);
490 >  exit_client(client_p, reason);
491   }
492  
493   /* find_person()
# Line 472 | Line 497 | update_client_exit_stats(struct Client *
497   * side effects - find person by (nick)name
498   */
499   struct Client *
500 < find_person(const struct Client *const source_p, const char *name)
500 > find_person(const struct Client *source_p, const char *name)
501   {
502    struct Client *target_p = NULL;
503  
# Line 503 | Line 528 | find_chasing(struct Client *source_p, co
528    if (IsDigit(*name))
529      return NULL;
530  
531 <  target_p = whowas_get_history(name, (time_t)ConfigGeneral.kill_chase_time_limit);
507 <
531 >  target_p = whowas_get_history(name, ConfigGeneral.kill_chase_time_limit);
532    if (!target_p)
509  {
533      sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, name);
511    return NULL;
512  }
534  
535    return target_p;
536   }
537  
538   /*
539 < * get_client_name -  Return the name of the client
539 > * client_get_name -  Return the name of the client
540   *    for various tracking and
541   *      admin purposes. The main purpose of this function is to
542   *      return the "socket host" name of the client, if that
# Line 533 | Line 554 | find_chasing(struct Client *source_p, co
554   *        to modify what it points!!!
555   */
556   const char *
557 < get_client_name(const struct Client *client_p, enum addr_mask_type type)
557 > client_get_name(const struct Client *client_p, enum addr_mask_type type)
558   {
559 <  static char buf[HOSTLEN * 2 + USERLEN + 5];
559 >  static char buf[HOSTLEN * 2 + USERLEN + 4];  /* +4 for [,@,],\0 */
560  
561    if (!MyConnect(client_p))
562      return client_p->name;
# Line 576 | Line 597 | get_client_name(const struct Client *cli
597   void
598   free_exited_clients(void)
599   {
600 <  dlink_node *node = NULL, *node_next = NULL;
600 >  dlink_node *node, *node_next;
601  
602    DLINK_FOREACH_SAFE(node, node_next, dead_list.head)
603    {
604 <    free_client(node->data);
604 >    client_free(node->data);
605      dlinkDelete(node, &dead_list);
606      free_dlink_node(node);
607    }
# Line 595 | Line 616 | free_exited_clients(void)
616   static void
617   exit_one_client(struct Client *source_p, const char *comment)
618   {
619 <  dlink_node *node = NULL, *node_next = NULL;
619 >  dlink_node *node, *node_next;
620  
621    assert(!IsMe(source_p));
622    assert(source_p != &me);
623  
624    if (IsClient(source_p))
625    {
626 +    if (HasUMode(source_p, UMODE_OPER))
627 +      --Count.oper;
628 +    if (HasUMode(source_p, UMODE_INVISIBLE))
629 +      --Count.invisi;
630 +
631      dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list);
632      dlinkDelete(&source_p->node, &global_client_list);
633  
# Line 611 | Line 637 | exit_one_client(struct Client *source_p,
637       * that the client can show the "**signoff" message).
638       * (Note: The notice is to the local clients *only*)
639       */
640 <    sendto_common_channels_local(source_p, 0, 0, ":%s!%s@%s QUIT :%s",
640 >    sendto_common_channels_local(source_p, 0, 0, 0, ":%s!%s@%s QUIT :%s",
641                                   source_p->name, source_p->username,
642                                   source_p->host, comment);
643  
644      DLINK_FOREACH_SAFE(node, node_next, source_p->channel.head)
645        remove_user_from_channel(node->data);
646  
647 +    client_clear_svstags(&source_p->svstags);
648 +
649      whowas_add_history(source_p, 0);
650      whowas_off_history(source_p);
651  
652      watch_check_hash(source_p, RPL_LOGOFF);
625
626    if (MyConnect(source_p))
627    {
628      clear_invites_client(source_p);
629      del_all_accepts(source_p);
630    }
653    }
654    else if (IsServer(source_p))
655    {
656 <    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list);
657 <    dlinkDelete(&source_p->node, &global_client_list);
656 >    sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE,
657 >                         "Server %s split from %s",
658 >                         source_p->name, source_p->servptr->name);
659  
660 <    if ((node = dlinkFindDelete(&global_server_list, source_p)))
661 <      free_dlink_node(node);
660 >    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list);
661 >    dlinkDelete(&source_p->node, &global_server_list);
662    }
663  
664    /* Remove source_p from the client lists */
# Line 646 | Line 669 | exit_one_client(struct Client *source_p,
669      hash_del_client(source_p);
670  
671    if (HasFlag(source_p, FLAGS_USERHOST))
672 <    userhost_del(source_p->username, source_p->host, !MyConnect(source_p));
650 <
651 <  update_client_exit_stats(source_p);
672 >    userhost_del(source_p->sockhost, !MyConnect(source_p));
673  
674    /* Check to see if the client isn't already on the dead list */
675    assert(dlinkFind(&dead_list, source_p) == NULL);
# Line 667 | Line 688 | exit_one_client(struct Client *source_p,
688   static void
689   recurse_remove_clients(struct Client *source_p, const char *comment)
690   {
691 <  dlink_node *node = NULL, *node_next = NULL;
691 >  dlink_node *node, *node_next;
692  
693    DLINK_FOREACH_SAFE(node, node_next, source_p->serv->client_list.head)
694      exit_one_client(node->data, comment);
# Line 699 | Line 720 | recurse_remove_clients(struct Client *so
720   void
721   exit_client(struct Client *source_p, const char *comment)
722   {
702  dlink_node *node = NULL;
703
723    assert(!IsMe(source_p));
724    assert(source_p != &me);
725  
726    if (MyConnect(source_p))
727    {
728 <    /* DO NOT REMOVE. exit_client can be called twice after a failed
729 <     * read/write.
728 >    /*
729 >     * DO NOT REMOVE. exit_client can be called twice after a failed read/write.
730       */
731      if (HasFlag(source_p, FLAGS_CLOSING))
732        return;
# Line 720 | Line 739 | exit_client(struct Client *source_p, con
739        ipcache_remove_address(&source_p->connection->ip);
740      }
741  
742 <    delete_auth(&source_p->connection->auth);
742 >    if (source_p->connection->auth)
743 >    {
744 >      auth_delete(source_p->connection->auth);
745 >      source_p->connection->auth = NULL;
746 >    }
747  
748      if (IsClient(source_p))
749      {
750 <      time_t on_for = CurrentTime - source_p->connection->firsttime;
728 <
729 <      assert(Count.local > 0);
730 <
731 <      --Count.local;
750 >      dlink_node *node;
751  
752        if (HasUMode(source_p, UMODE_OPER))
753          if ((node = dlinkFindDelete(&oper_list, source_p)))
# Line 740 | Line 759 | exit_client(struct Client *source_p, con
759        if (source_p->connection->list_task)
760          free_list_task(source_p);
761  
762 +      clear_invite_list(&source_p->connection->invited);
763 +      del_all_accepts(source_p);
764        watch_del_watch_list(source_p);
744      client_clear_svstags(source_p);
765  
766        sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE,
767                             "Client exiting: %s (%s@%s) [%s] [%s]",
768 <                           source_p->name, source_p->username, source_p->host, comment,
769 <                           source_p->sockhost);
768 >                           source_p->name, source_p->username, source_p->realhost,
769 >                           source_p->sockhost, comment);
770  
771 <      ilog(LOG_TYPE_USER, "%s (%3u:%02u:%02u): %s!%s@%s %llu/%llu",
772 <           date_ctime(source_p->connection->firsttime), (unsigned int)(on_for / 3600),
773 <           (unsigned int)((on_for % 3600)/60), (unsigned int)(on_for % 60),
771 >      ilog(LOG_TYPE_USER, "%s (%ju): %s!%s@%s %s %s %ju/%ju :%s",
772 >           date_ctime(source_p->connection->firsttime),
773 >           CurrentTime - source_p->connection->firsttime,
774             source_p->name, source_p->username, source_p->host,
775 <           source_p->connection->send.bytes>>10,
776 <           source_p->connection->recv.bytes>>10);
775 >           source_p->sockhost, source_p->account,
776 >           source_p->connection->send.bytes >> 10,
777 >           source_p->connection->recv.bytes >> 10, source_p->info);
778      }
779      else if (IsServer(source_p))
780      {
760      assert(Count.myserver > 0);
761
762      --Count.myserver;
763
781        assert(dlinkFind(&local_server_list, source_p));
782        dlinkDelete(&source_p->connection->lclient_node, &local_server_list);
783      }
# Line 790 | Line 807 | exit_client(struct Client *source_p, con
807    }
808    else if (IsClient(source_p) && HasFlag(source_p->servptr, FLAGS_EOB))
809      sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE,
810 <                         "Client exiting at %s: %s (%s@%s) [%s]",
810 >                         "Client exiting at %s: %s (%s@%s) [%s] [%s]",
811                           source_p->servptr->name, source_p->name,
812 <                         source_p->username, source_p->host, comment);
812 >                         source_p->username, source_p->realhost, source_p->sockhost, comment);
813  
814    if (IsServer(source_p))
815    {
# Line 820 | Line 837 | exit_client(struct Client *source_p, con
837  
838      if (MyConnect(source_p))
839      {
823      int connected = CurrentTime - source_p->connection->firsttime;
840        sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
841 <                           "%s was connected for %d day%s, %2d:%02d:%02d. %llu/%llu sendK/recvK.",
842 <                           source_p->name, connected/86400, (connected/86400 == 1) ? "" : "s",
827 <                           (connected % 86400) / 3600, (connected % 3600) / 60, connected % 60,
841 >                           "%s was connected for %s. %ju/%ju sendK/recvK.",
842 >                           source_p->name, time_dissect(CurrentTime - source_p->connection->firsttime),
843                             source_p->connection->send.bytes >> 10,
844                             source_p->connection->recv.bytes >> 10);
845 <      ilog(LOG_TYPE_IRCD, "%s was connected for %d day%s, %2d:%02d:%02d. %llu/%llu sendK/recvK.",
846 <           source_p->name, connected/86400, (connected/86400 == 1) ? "" : "s",
832 <           (connected % 86400) / 3600, (connected % 3600) / 60, connected % 60,
845 >      ilog(LOG_TYPE_IRCD, "%s was connected for %s. %ju/%ju sendK/recvK.",
846 >           source_p->name, time_dissect(CurrentTime - source_p->connection->firsttime),
847             source_p->connection->send.bytes >> 10,
848             source_p->connection->recv.bytes >> 10);
849      }
850    }
851    else if (IsClient(source_p) && !HasFlag(source_p, FLAGS_KILLED))
852 <    sendto_server(source_p->from, 0, 0, ":%s QUIT :%s",
839 <                  source_p->id, comment);
852 >    sendto_server(source_p->from, 0, 0, ":%s QUIT :%s", source_p->id, comment);
853  
854    /* The client *better* be off all of the lists */
855    assert(dlinkFind(&unknown_list, source_p) == NULL);
856    assert(dlinkFind(&local_client_list, source_p) == NULL);
857    assert(dlinkFind(&local_server_list, source_p) == NULL);
858    assert(dlinkFind(&oper_list, source_p) == NULL);
859 +  assert(dlinkFind(&listing_client_list, source_p) == NULL);
860  
861    exit_one_client(source_p, comment);
862   }
# Line 889 | Line 903 | dead_link_on_read(struct Client *client_
903    dbuf_clear(&client_p->connection->buf_recvq);
904    dbuf_clear(&client_p->connection->buf_sendq);
905  
906 <  current_error = get_sockerr(client_p->connection->fd.fd);
906 >  current_error = get_sockerr(client_p->connection->fd->fd);
907  
908    if (IsServer(client_p) || IsHandshake(client_p))
909    {
896    int connected = CurrentTime - client_p->connection->firsttime;
897
910      if (error == 0)
911      {
912        /* Admins get the real IP */
913        sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
914                             "Server %s closed the connection",
915 <                           get_client_name(client_p, SHOW_IP));
915 >                           client_get_name(client_p, SHOW_IP));
916  
917        /* Opers get a masked IP */
918        sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
919                             "Server %s closed the connection",
920 <                           get_client_name(client_p, MASK_IP));
920 >                           client_get_name(client_p, MASK_IP));
921  
922        ilog(LOG_TYPE_IRCD, "Server %s closed the connection",
923 <           get_client_name(client_p, SHOW_IP));
923 >           client_get_name(client_p, SHOW_IP));
924      }
925      else
926      {
927        report_error(L_ADMIN, "Lost connection to %s: %s",
928 <                   get_client_name(client_p, SHOW_IP), current_error);
928 >                   client_get_name(client_p, SHOW_IP), current_error);
929        report_error(L_OPER, "Lost connection to %s: %s",
930 <                   get_client_name(client_p, MASK_IP), current_error);
930 >                   client_get_name(client_p, MASK_IP), current_error);
931      }
932  
933      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
934 <                         "%s was connected for %d day%s, %2d:%02d:%02d",
935 <                         client_p->name, connected/86400,
924 <                         (connected/86400 == 1) ? "" : "s",
925 <                         (connected % 86400) / 3600, (connected % 3600) / 60,
926 <                         connected % 60);
934 >                         "%s was connected for %s",
935 >                         client_p->name, time_dissect(CurrentTime - client_p->connection->firsttime));
936    }
937  
938    if (error == 0)
# Line 948 | Line 957 | exit_aborted_clients(void)
957      target_p = ptr->data;
958      eac_next = ptr->next;
959  
960 +    dlinkDelete(ptr, &abort_list);
961 +    free_dlink_node(ptr);
962 +
963      if (target_p == NULL)
964      {
965        sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
966                             "Warning: null client on abort_list!");
955      dlinkDelete(ptr, &abort_list);
956      free_dlink_node(ptr);
967        continue;
968      }
969  
960    dlinkDelete(ptr, &abort_list);
961
970      if (HasFlag(target_p, FLAGS_SENDQEX))
971        notice = "Max SendQ exceeded";
972      else
973        notice = "Write error: connection closed";
974  
975      exit_client(target_p, notice);
968    free_dlink_node(ptr);
976    }
977   }
978  
# Line 984 | Line 991 | del_accept(struct split_nuh_item *accept
991   {
992    dlinkDelete(&accept_p->node, &client_p->connection->acceptlist);
993  
994 <  MyFree(accept_p->nickptr);
995 <  MyFree(accept_p->userptr);
996 <  MyFree(accept_p->hostptr);
997 <  MyFree(accept_p);
994 >  xfree(accept_p->nickptr);
995 >  xfree(accept_p->userptr);
996 >  xfree(accept_p->hostptr);
997 >  xfree(accept_p);
998   }
999  
1000   struct split_nuh_item *
# Line 995 | Line 1002 | find_accept(const char *nick, const char
1002              const char *host, struct Client *client_p,
1003              int (*cmpfunc)(const char *, const char *))
1004   {
1005 <  dlink_node *node = NULL;
1005 >  dlink_node *node;
1006  
1007    DLINK_FOREACH(node, client_p->connection->acceptlist.head)
1008    {
# Line 1021 | Line 1028 | int
1028   accept_message(struct Client *source,
1029                 struct Client *target)
1030   {
1031 <  dlink_node *node = NULL;
1031 >  dlink_node *node;
1032  
1033    if (HasFlag(source, FLAGS_SERVICE) ||
1034        (HasUMode(source, UMODE_OPER) && ConfigGeneral.opers_bypass_callerid))
# Line 1048 | Line 1055 | accept_message(struct Client *source,
1055   void
1056   del_all_accepts(struct Client *client_p)
1057   {
1058 <  dlink_node *node = NULL, *node_next = NULL;
1058 >  dlink_node *node, *node_next;
1059  
1060    DLINK_FOREACH_SAFE(node, node_next, client_p->connection->acceptlist.head)
1061      del_accept(node->data, client_p);
# Line 1059 | Line 1066 | client_get_idle_time(const struct Client
1066                       const struct Client *target_p)
1067   {
1068    unsigned int idle = 0;
1062  unsigned int min_idle = 0;
1063  unsigned int max_idle = 0;
1069    const struct ClassItem *const class = get_class_ptr(&target_p->connection->confs);
1070  
1071    if (!(class->flags & CLASS_FLAGS_FAKE_IDLE) || target_p == source_p)
# Line 1070 | Line 1075 | client_get_idle_time(const struct Client
1075        !(class->flags & CLASS_FLAGS_HIDE_IDLE_FROM_OPERS))
1076      return CurrentTime - target_p->connection->last_privmsg;
1077  
1078 <  min_idle = class->min_idle;
1079 <  max_idle = class->max_idle;
1078 >  const unsigned int min_idle = class->min_idle;
1079 >  const unsigned int max_idle = class->max_idle;
1080  
1081    if (min_idle == max_idle)
1082      return min_idle;
# Line 1081 | Line 1086 | client_get_idle_time(const struct Client
1086    else
1087      idle = CurrentTime - target_p->connection->last_privmsg;
1088  
1089 <  if (!max_idle)
1085 <    idle = 0;
1086 <  else
1089 >  if (max_idle)
1090      idle %= max_idle;
1091 +  else
1092 +    idle = 0;
1093  
1094    if (idle < min_idle)
1095      idle = min_idle + (idle % (max_idle - min_idle));
# Line 1108 | Line 1113 | client_init(void)
1113      .when = 5
1114    };
1115  
1111  client_pool = mp_pool_new(sizeof(struct Client), MP_CHUNK_SIZE_CLIENT);
1112  connection_pool = mp_pool_new(sizeof(struct Connection), MP_CHUNK_SIZE_CONNECTION);
1116    event_add(&event_ping, NULL);
1117   }

Comparing ircd-hybrid/trunk/src/client.c (property svn:keywords):
Revision 6513 by michael, Sun Sep 6 18:32:38 2015 UTC vs.
Revision 8385 by michael, Fri Mar 16 20:09:55 2018 UTC

# Line 1 | Line 1
1 < Id Revision
1 > Id

Diff Legend

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