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-7.2/src/client.c (file contents), Revision 1011 by michael, Fri Sep 18 10:14:09 2009 UTC vs.
ircd-hybrid-8/src/client.c (file contents), Revision 1176 by michael, Sun Aug 14 11:24:24 2011 UTC

# Line 31 | Line 31
31   #include "fdlist.h"
32   #include "hash.h"
33   #include "irc_string.h"
34 #include "sprintf_irc.h"
34   #include "ircd.h"
35   #include "s_gline.h"
36   #include "numeric.h"
# Line 76 | Line 75 | static dlink_node *eac_next;  /* next ab
75  
76   static void check_pings_list(dlink_list *);
77   static void check_unknowns_list(void);
78 < static void ban_them(struct Client *client_p, struct ConfItem *conf);
78 > static void ban_them(struct Client *, struct ConfItem *);
79  
80  
81   /* init_client()
# Line 124 | Line 123 | make_client(struct Client *from)
123      client_p->localClient = BlockHeapAlloc(lclient_heap);
124      client_p->localClient->registration = REG_INIT;
125      /* as good a place as any... */
126 <    dlinkAdd(client_p, make_dlink_node(), &unknown_list);
126 >    dlinkAdd(client_p, &client_p->localClient->lclient_node, &unknown_list);
127    }
128    else
129      client_p->from = from; /* 'from' of local client is self! */
# Line 253 | Line 252 | check_pings_list(dlink_list *list)
252        continue;
253      }
254  
256    if (GlobalSetOptions.idletime && IsClient(client_p))
257    {
258      if (!IsExemptKline(client_p) && !IsOper(client_p) &&
259          !IsIdlelined(client_p) &&
260          ((CurrentTime - client_p->localClient->last) > GlobalSetOptions.idletime))
261      {
262        struct ConfItem *conf;
263        struct AccessItem *aconf;
264
265        conf = make_conf_item(KLINE_TYPE);
266        aconf = (struct AccessItem *)map_to_conf(conf);
267
268        DupString(aconf->host, client_p->host);
269        DupString(aconf->reason, "idle exceeder");
270        DupString(aconf->user, client_p->username);
271        aconf->hold = CurrentTime + 60;
272        add_temp_line(conf);
273
274        sendto_realops_flags(UMODE_ALL, L_ALL,
275                             "Idle time limit exceeded for %s - temp k-lining",
276                             get_client_name(client_p, HIDE_IP));
277        exit_client(client_p, &me, aconf->reason);
278        continue;
279      }
280    }
281
255      if (!IsRegistered(client_p))
256        ping = CONNECTTIMEOUT, pingwarn = 0;
257      else
# Line 318 | Line 291 | check_pings_list(dlink_list *list)
291                   get_client_name(client_p, HIDE_IP));
292            }
293  
294 <          ircsprintf(scratch, "Ping timeout: %d seconds",
295 <                     (int)(CurrentTime - client_p->lasttime));
294 >          snprintf(scratch, sizeof(scratch), "Ping timeout: %d seconds",
295 >                   (int)(CurrentTime - client_p->lasttime));
296            exit_client(client_p, &me, scratch);
297          }
298          else if (!IsPingWarning(client_p) && pingwarn > 0 &&
# Line 554 | Line 527 | ban_them(struct Client *client_p, struct
527   static void
528   update_client_exit_stats(struct Client *client_p)
529   {
530 <  if (IsServer(client_p))
558 <  {
559 <    sendto_realops_flags(UMODE_EXTERNAL, L_ALL,
560 <                         "Server %s split from %s",
561 <                         client_p->name, client_p->servptr->name);
562 <  }
563 <  else if (IsClient(client_p))
530 >  if (IsClient(client_p))
531    {
532 +    assert(Count.total > 0);
533      --Count.total;
534      if (IsOper(client_p))
535        --Count.oper;
536      if (IsInvisible(client_p))
537        --Count.invisi;
538    }
539 +  else if (IsServer(client_p))
540 +    sendto_realops_flags(UMODE_EXTERNAL, L_ALL, "Server %s split from %s",
541 +                         client_p->name, client_p->servptr->name);
542  
543    if (splitchecking && !splitmode)
544      check_splitmode(NULL);
# Line 595 | Line 566 | find_person(const struct Client *client_
566      }
567    }
568    else
569 <    c2ptr = find_client(name);
569 >    c2ptr = hash_find_client(name);
570  
571    return ((c2ptr != NULL && IsClient(c2ptr)) ? c2ptr : NULL);
572   }
# Line 615 | Line 586 | find_chasing(struct Client *client_p, st
586      *chasing = 0;
587  
588    if (who)
589 <    return(who);
589 >    return who;
590  
591    if (IsDigit(*user))
592 <    return(NULL);
592 >    return NULL;
593  
594    if ((who = get_history(user,
595                          (time_t)ConfigFileEntry.kill_chase_time_limit))
# Line 626 | Line 597 | find_chasing(struct Client *client_p, st
597    {
598      sendto_one(source_p, form_str(ERR_NOSUCHNICK),
599                 me.name, source_p->name, user);
600 <    return(NULL);
600 >    return NULL;
601    }
602  
603    if (chasing)
604      *chasing = 1;
605  
606 <  return(who);
606 >  return who;
607   }
608  
609   /*
# Line 654 | Line 625 | find_chasing(struct Client *client_p, st
625   *        to modify what it points!!!
626   */
627   const char *
628 < get_client_name(struct Client *client, int showip)
628 > get_client_name(const struct Client *client, int showip)
629   {
630    static char nbuf[HOSTLEN * 2 + USERLEN + 5];
631  
632    assert(client != NULL);
633  
634    if (irccmp(client->name, client->host) == 0)
635 <    return(client->name);
635 >    return client->name;
636  
637    if (ConfigServerHide.hide_server_ips)
638      if (IsServer(client) || IsConnecting(client) || IsHandshake(client))
# Line 677 | Line 648 | get_client_name(struct Client *client, i
648      case SHOW_IP:
649        if (MyConnect(client))
650        {
651 <        ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
652 <                   client->sockhost);
651 >        snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
652 >                 client->name,
653 >                 client->username, client->sockhost);
654          break;
655        }
656      case MASK_IP:
657 <      ircsprintf(nbuf, "%s[%s@255.255.255.255]", client->name,
658 <                 client->username);
657 >      snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]",
658 >               client->name, client->username);
659        break;
660      default:
661 <      ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
662 <                 client->host);
661 >      snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
662 >               client->name,
663 >               client->username, client->host);
664    }
665  
666 <  return(nbuf);
666 >  return nbuf;
667   }
668  
669   void
# Line 719 | Line 692 | exit_one_client(struct Client *source_p,
692  
693    assert(!IsMe(source_p));
694  
695 <  if (IsServer(source_p))
723 <  {
724 <    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list);
725 <
726 <    if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL)
727 <      free_dlink_node(lp);
728 <  }
729 <  else if (IsClient(source_p))
695 >  if (IsClient(source_p))
696    {
697      if (source_p->servptr->serv != NULL)
698        dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list);
699  
700 <    /* If a person is on a channel, send a QUIT notice
701 <    ** to every client (person) on the same channel (so
702 <    ** that the client can show the "**signoff" message).
703 <    ** (Note: The notice is to the local clients *only*)
704 <    */
700 >    /*
701 >     * If a person is on a channel, send a QUIT notice
702 >     * to every client (person) on the same channel (so
703 >     * that the client can show the "**signoff" message).
704 >     * (Note: The notice is to the local clients *only*)
705 >     */
706      sendto_common_channels_local(source_p, 0, ":%s!%s@%s QUIT :%s",
707                                   source_p->name, source_p->username,
708                                   source_p->host, quitmsg);
# Line 756 | Line 723 | exit_one_client(struct Client *source_p,
723        del_all_accepts(source_p);
724      }
725    }
726 +  else if (IsServer(source_p))
727 +  {
728 +    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list);
729 +
730 +    if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL)
731 +      free_dlink_node(lp);
732 +  }
733  
734    /* Remove source_p from the client lists */
735    if (HasID(source_p))
# Line 795 | Line 769 | exit_one_client(struct Client *source_p,
769   static void
770   recurse_send_quits(struct Client *original_source_p, struct Client *source_p,
771                     struct Client *from, struct Client *to, const char *comment,
772 <                   const char *splitstr, const char *myname)
772 >                   const char *splitstr)
773   {
774    dlink_node *ptr, *next;
775    struct Client *target_p;
776 <  int hidden = match(myname, source_p->name);
776 >  int hidden = match(me.name, source_p->name); /* XXX */
777  
778    assert(to != source_p);  /* should be already removed from serv_list */
779  
# Line 818 | Line 792 | recurse_send_quits(struct Client *origin
792  
793    DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head)
794      recurse_send_quits(original_source_p, ptr->data, from, to,
795 <                       comment, splitstr, myname);
795 >                       comment, splitstr);
796  
797    if (!hidden && ((source_p == original_source_p && to != from) ||
798                    !IsCapable(to, CAP_QS)))
# Line 859 | Line 833 | static void
833   remove_dependents(struct Client *source_p, struct Client *from,
834                    const char *comment, const char *splitstr)
835   {
836 <  struct Client *to;
863 <  struct ConfItem *conf;
864 <  static char myname[HOSTLEN+1];
865 <  dlink_node *ptr;
836 >  dlink_node *ptr = NULL;
837  
838    DLINK_FOREACH(ptr, serv_list.head)
839 <  {
840 <    to = ptr->data;
870 <
871 <    if ((conf = to->serv->sconf) != NULL)
872 <      strlcpy(myname, my_name_for_link(conf), sizeof(myname));
873 <    else
874 <      strlcpy(myname, me.name, sizeof(myname));
875 <    recurse_send_quits(source_p, source_p, from, to,
876 <                       comment, splitstr, myname);
877 <  }
839 >    recurse_send_quits(source_p, source_p, from, ptr->data,
840 >                       comment, splitstr);
841  
842    recurse_remove_clients(source_p, splitstr);
843   }
# Line 900 | Line 863 | remove_dependents(struct Client *source_
863   void
864   exit_client(struct Client *source_p, struct Client *from, const char *comment)
865   {
866 <  dlink_node *m;
866 >  dlink_node *m = NULL;
867  
868    if (MyConnect(source_p))
869    {
# Line 929 | Line 892 | exit_client(struct Client *source_p, str
892       */
893      if (!IsRegistered(source_p))
894      {
895 <      if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL)
896 <        free_dlink_node(m);
895 >      assert(dlinkFind(&unknown_list, source_p));
896 >
897 >      dlinkDelete(&source_p->localClient->lclient_node, &unknown_list);
898      }
899      else if (IsClient(source_p))
900      {
901 +      assert(Count.local > 0);
902        Count.local--;
903  
904        if (IsOper(source_p))
# Line 942 | Line 907 | exit_client(struct Client *source_p, str
907            free_dlink_node(m);
908        }
909  
910 +      assert(dlinkFind(&local_client_list, source_p));
911        dlinkDelete(&source_p->localClient->lclient_node, &local_client_list);
912 +
913        if (source_p->localClient->list_task != NULL)
914          free_list_task(source_p->localClient->list_task, source_p);
915  
# Line 1139 | Line 1106 | dead_link_on_read(struct Client *client_
1106      strlcpy(errmsg, "Remote host closed the connection",
1107              sizeof(errmsg));
1108    else
1109 <    ircsprintf(errmsg, "Read error: %s",
1110 <               strerror(current_error));
1109 >    snprintf(errmsg, sizeof(errmsg), "Read error: %s",
1110 >             strerror(current_error));
1111  
1112    exit_client(client_p, &me, errmsg);
1113   }
# Line 1299 | Line 1266 | change_local_nick(struct Client *client_
1266        source_p->tsinfo = CurrentTime;
1267        clear_ban_cache_client(source_p);
1268        watch_check_hash(source_p, RPL_LOGOFF);
1269 +
1270 +      if (HasUMode(source_p, UMODE_REGISTERED))
1271 +      {
1272 +        unsigned int oldmodes = source_p->umodes;
1273 +        char modebuf[IRCD_BUFSIZE] = { '\0' };
1274 +
1275 +        DelUMode(source_p, UMODE_REGISTERED);
1276 +        send_umode(source_p, source_p, oldmodes, 0xffffffff, modebuf);
1277 +      }
1278      }
1279  
1280      /* XXX - the format of this notice should eventually be changed

Diff Legend

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