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

Comparing:
ircd-hybrid-7.2/src/client.c (file contents), Revision 889 by michael, Thu Nov 1 12:59:05 2007 UTC vs.
ircd-hybrid-7.3/src/client.c (file contents), Revision 1124 by michael, Mon Feb 7 11:45:27 2011 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 < #include "tools.h"
26 > #include "list.h"
27   #include "client.h"
28   #include "channel_mode.h"
29   #include "common.h"
# 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"
36 #include "list.h"
35   #include "s_gline.h"
36   #include "numeric.h"
37   #include "packet.h"
# Line 77 | 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 264 | Line 262 | check_pings_list(dlink_list *list)
262          struct AccessItem *aconf;
263  
264          conf = make_conf_item(KLINE_TYPE);
265 <        aconf = (struct AccessItem *)map_to_conf(conf);
265 >        aconf = map_to_conf(conf);
266  
267          DupString(aconf->host, client_p->host);
268          DupString(aconf->reason, "idle exceeder");
# Line 319 | Line 317 | check_pings_list(dlink_list *list)
317                   get_client_name(client_p, HIDE_IP));
318            }
319  
320 <          ircsprintf(scratch, "Ping timeout: %d seconds",
321 <                     (int)(CurrentTime - client_p->lasttime));
320 >          snprintf(scratch, sizeof(scratch), "Ping timeout: %d seconds",
321 >                   (int)(CurrentTime - client_p->lasttime));
322            exit_client(client_p, &me, scratch);
323          }
324          else if (!IsPingWarning(client_p) && pingwarn > 0 &&
# Line 557 | Line 555 | update_client_exit_stats(struct Client *
555   {
556    if (IsServer(client_p))
557    {
558 <    sendto_realops_flags(UMODE_EXTERNAL, L_ALL,
559 <                         "Server %s split from %s",
562 <                         client_p->name, client_p->servptr->name);
558 >    sendto_realops_flags(UMODE_EXTERNAL, L_ALL, "Server %s split from %s",
559 >                         client_p->name, client_p->servptr->name);
560    }
561    else if (IsClient(client_p))
562    {
563 +    assert(Count.total > 0);
564      --Count.total;
565      if (IsOper(client_p))
566        --Count.oper;
# Line 655 | Line 653 | find_chasing(struct Client *client_p, st
653   *        to modify what it points!!!
654   */
655   const char *
656 < get_client_name(struct Client *client, int showip)
656 > get_client_name(const struct Client *client, int showip)
657   {
658    static char nbuf[HOSTLEN * 2 + USERLEN + 5];
659  
660    assert(client != NULL);
661  
662    if (irccmp(client->name, client->host) == 0)
663 <    return(client->name);
663 >    return client->name;
664  
665    if (ConfigServerHide.hide_server_ips)
666      if (IsServer(client) || IsConnecting(client) || IsHandshake(client))
# Line 678 | Line 676 | get_client_name(struct Client *client, i
676      case SHOW_IP:
677        if (MyConnect(client))
678        {
679 <        ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
680 <                   client->sockhost);
679 >        snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
680 >                 client->name,
681 >                 client->username, client->sockhost);
682          break;
683        }
684      case MASK_IP:
685 <      ircsprintf(nbuf, "%s[%s@255.255.255.255]", client->name,
686 <                 client->username);
685 >      snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]",
686 >               client->name, client->username);
687        break;
688      default:
689 <      ircsprintf(nbuf, "%s[%s@%s]", client->name, client->username,
690 <                 client->host);
689 >      snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
690 >               client->name,
691 >               client->username, client->host);
692    }
693  
694 <  return(nbuf);
694 >  return nbuf;
695   }
696  
697   void
# Line 720 | Line 720 | exit_one_client(struct Client *source_p,
720  
721    assert(!IsMe(source_p));
722  
723 <  if (IsServer(source_p))
724 <  {
725 <    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list);
726 <
727 <    if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL)
728 <      free_dlink_node(lp);
729 <  }
730 <  else if (IsClient(source_p))
723 >  if (IsClient(source_p))
724    {
725      if (source_p->servptr->serv != NULL)
726        dlinkDelete(&source_p->lnode, &source_p->servptr->serv->client_list);
727  
728 <    /* If a person is on a channel, send a QUIT notice
729 <    ** to every client (person) on the same channel (so
730 <    ** that the client can show the "**signoff" message).
731 <    ** (Note: The notice is to the local clients *only*)
732 <    */
728 >    /*
729 >     * If a person is on a channel, send a QUIT notice
730 >     * to every client (person) on the same channel (so
731 >     * that the client can show the "**signoff" message).
732 >     * (Note: The notice is to the local clients *only*)
733 >     */
734      sendto_common_channels_local(source_p, 0, ":%s!%s@%s QUIT :%s",
735                                   source_p->name, source_p->username,
736                                   source_p->host, quitmsg);
# Line 757 | Line 751 | exit_one_client(struct Client *source_p,
751        del_all_accepts(source_p);
752      }
753    }
754 +  else if (IsServer(source_p))
755 +  {
756 +    dlinkDelete(&source_p->lnode, &source_p->servptr->serv->server_list);
757 +
758 +    if ((lp = dlinkFindDelete(&global_serv_list, source_p)) != NULL)
759 +      free_dlink_node(lp);
760 +  }
761  
762    /* Remove source_p from the client lists */
763    if (HasID(source_p))
# Line 796 | Line 797 | exit_one_client(struct Client *source_p,
797   static void
798   recurse_send_quits(struct Client *original_source_p, struct Client *source_p,
799                     struct Client *from, struct Client *to, const char *comment,
800 <                   const char *splitstr, const char *myname)
800 >                   const char *splitstr)
801   {
802    dlink_node *ptr, *next;
803    struct Client *target_p;
804 <  int hidden = match(myname, source_p->name);
804 >  int hidden = match(me.name, source_p->name); /* XXX */
805  
806    assert(to != source_p);  /* should be already removed from serv_list */
807  
# Line 819 | Line 820 | recurse_send_quits(struct Client *origin
820  
821    DLINK_FOREACH_SAFE(ptr, next, source_p->serv->server_list.head)
822      recurse_send_quits(original_source_p, ptr->data, from, to,
823 <                       comment, splitstr, myname);
823 >                       comment, splitstr);
824  
825    if (!hidden && ((source_p == original_source_p && to != from) ||
826                    !IsCapable(to, CAP_QS)))
# Line 860 | Line 861 | static void
861   remove_dependents(struct Client *source_p, struct Client *from,
862                    const char *comment, const char *splitstr)
863   {
864 <  struct Client *to;
864 <  struct ConfItem *conf;
865 <  static char myname[HOSTLEN+1];
866 <  dlink_node *ptr;
864 >  dlink_node *ptr = NULL;
865  
866    DLINK_FOREACH(ptr, serv_list.head)
867 <  {
868 <    to = ptr->data;
871 <
872 <    if ((conf = to->serv->sconf) != NULL)
873 <      strlcpy(myname, my_name_for_link(conf), sizeof(myname));
874 <    else
875 <      strlcpy(myname, me.name, sizeof(myname));
876 <    recurse_send_quits(source_p, source_p, from, to,
877 <                       comment, splitstr, myname);
878 <  }
867 >    recurse_send_quits(source_p, source_p, from, ptr->data,
868 >                       comment, splitstr);
869  
870    recurse_remove_clients(source_p, splitstr);
871   }
# Line 901 | Line 891 | remove_dependents(struct Client *source_
891   void
892   exit_client(struct Client *source_p, struct Client *from, const char *comment)
893   {
894 <  dlink_node *m;
894 >  dlink_node *m = NULL;
895  
896    if (MyConnect(source_p))
897    {
# Line 916 | Line 906 | exit_client(struct Client *source_p, str
906      if (IsIpHash(source_p))
907        remove_one_ip(&source_p->localClient->ip);
908  
909 <    delete_auth(source_p);
909 >    if (source_p->localClient->auth)
910 >    {
911 >      delete_auth(source_p->localClient->auth);
912 >      source_p->localClient->auth = NULL;
913 >    }
914  
915      /* This source_p could have status of one of STAT_UNKNOWN, STAT_CONNECTING
916       * STAT_HANDSHAKE or STAT_UNKNOWN
# Line 931 | Line 925 | exit_client(struct Client *source_p, str
925      }
926      else if (IsClient(source_p))
927      {
928 +      assert(Count.local > 0);
929        Count.local--;
930  
931        if (IsOper(source_p))
# Line 1136 | Line 1131 | dead_link_on_read(struct Client *client_
1131      strlcpy(errmsg, "Remote host closed the connection",
1132              sizeof(errmsg));
1133    else
1134 <    ircsprintf(errmsg, "Read error: %s",
1135 <               strerror(current_error));
1134 >    snprintf(errmsg, sizeof(errmsg), "Read error: %s",
1135 >             strerror(current_error));
1136  
1137    exit_client(client_p, &me, errmsg);
1138   }
# Line 1257 | Line 1252 | del_all_accepts(struct Client *client_p)
1252      del_accept(ptr->data, client_p);
1253   }
1254  
1260 /* set_initial_nick()
1261 *
1262 * inputs
1263 * output
1264 * side effects -
1265 *
1266 * This function is only called to set up an initially registering
1267 * client.
1268 */
1269 void
1270 set_initial_nick(struct Client *client_p, struct Client *source_p,
1271                 const char *nick)
1272 {
1273 char buf[USERLEN + 1];
1274
1275  /* Client setting NICK the first time */
1276  
1277  /* This had to be copied here to avoid problems.. */
1278  source_p->tsinfo = CurrentTime;
1279  source_p->localClient->registration &= ~REG_NEED_NICK;
1280
1281  if (source_p->name[0])
1282    hash_del_client(source_p);
1283
1284  strlcpy(source_p->name, nick, sizeof(source_p->name));
1285  hash_add_client(source_p);
1286
1287  /* fd_desc is long enough */
1288  fd_note(&client_p->localClient->fd, "Nick: %s", nick);
1289  
1290  if (!source_p->localClient->registration)
1291  {
1292    strlcpy(buf, source_p->username, sizeof(buf));
1293
1294    /*
1295     * USER already received, now we have NICK.
1296     * *NOTE* For servers "NICK" *must* precede the
1297     * user message (giving USER before NICK is possible
1298     * only for local client connection!). register_user
1299     * may reject the client and call exit_client for it
1300     * --must test this and exit m_nick too!!!
1301     */
1302    register_local_user(client_p, source_p, nick, buf);
1303  }
1304 }
1305
1255   /* change_local_nick()
1256   *
1257   * inputs       - pointer to server

Diff Legend

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