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

Comparing ircd-hybrid-7.2/src/s_user.c (file contents):
Revision 589 by michael, Mon May 8 18:40:00 2006 UTC vs.
Revision 896 by michael, Sat Nov 3 08:54:09 2007 UTC

# Line 35 | Line 35
35   #include "irc_string.h"
36   #include "sprintf_irc.h"
37   #include "s_bsd.h"
38 #include "irc_getnameinfo.h"
38   #include "ircd.h"
39   #include "list.h"
40   #include "listener.h"
# Line 44 | Line 43
43   #include "s_conf.h"
44   #include "s_log.h"
45   #include "s_serv.h"
47 #include "s_stats.h"
46   #include "send.h"
47   #include "supported.h"
48   #include "whowas.h"
# Line 55 | Line 53
53   #include "s_misc.h"
54   #include "msg.h"
55   #include "pcre.h"
56 + #include "watch.h"
57  
58   int MaxClientCount     = 1;
59   int MaxConnectionCount = 1;
# Line 67 | Line 66 | static char umode_buffer[IRCD_BUFSIZE];
66   static void user_welcome(struct Client *);
67   static void report_and_set_user_flags(struct Client *, const struct AccessItem *);
68   static int check_xline(struct Client *);
70 static int check_regexp_xline(struct Client *);
69   static void introduce_client(struct Client *, struct Client *);
70   static void *uid_get(va_list);
71  
# Line 96 | Line 94 | unsigned int user_modes[256] =
94    0,                  /* @ */
95    0,                  /* A */
96    0,                  /* B */
97 <  0,                  /* C */
97 >  UMODE_CCONN_FULL,   /* C */
98    UMODE_DEAF,         /* D */
99    0,                  /* E */
100    0,                  /* F */
# Line 287 | Line 285 | register_local_user(struct Client *clien
285                      const char *nick, const char *username)
286   {
287    const struct AccessItem *aconf = NULL;
290  char ipaddr[HOSTIPLEN];
288    dlink_node *ptr = NULL;
289    dlink_node *m = NULL;
290  
# Line 339 | Line 336 | register_local_user(struct Client *clien
336  
337      if (IsNeedIdentd(aconf))
338      {
339 <      ServerStats->is_ref++;
339 >      ++ServerStats.is_ref;
340        sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
341                   "identd to use this server", me.name, source_p->name);
342        exit_client(source_p, &me, "Install identd");
# Line 368 | Line 365 | register_local_user(struct Client *clien
365  
366      if (!match_conf_password(pass, aconf))
367      {
368 <      ServerStats->is_ref++;
368 >      ++ServerStats.is_ref;
369        sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
370                   me.name, source_p->name);
371        exit_client(source_p, &me, "Bad Password");
# Line 398 | Line 395 | register_local_user(struct Client *clien
395      sendto_realops_flags(UMODE_FULL, L_ALL,
396                           "Too many clients, rejecting %s[%s].",
397                           nick, source_p->host);
398 <    ServerStats->is_ref++;
398 >    ++ServerStats.is_ref;
399      exit_client(source_p, &me, "Sorry, server is full - try later");
400      return;
401    }
# Line 410 | Line 407 | register_local_user(struct Client *clien
407  
408      sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)",
409                           nick, source_p->username, source_p->host);
410 <    ServerStats->is_ref++;
410 >    ++ServerStats.is_ref;
411      ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
412      exit_client(source_p, &me, tmpstr2);
413      return;
# Line 418 | Line 415 | register_local_user(struct Client *clien
415  
416    assert(source_p == client_p);
417  
418 <  /* end of valid user name check */
422 <  if (check_xline(source_p) || check_regexp_xline(source_p))
418 >  if (check_xline(source_p))
419      return;
420  
421    if (IsDead(client_p))
# Line 436 | Line 432 | register_local_user(struct Client *clien
432      hash_add_id(source_p);
433    }
434  
439  irc_getnameinfo((struct sockaddr *)&source_p->localClient->ip,
440                  source_p->localClient->ip.ss_len, ipaddr,
441                  HOSTIPLEN, NULL, 0, NI_NUMERICHOST);
442
435    sendto_realops_flags(UMODE_CCONN, L_ALL,
436                         "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
437                         nick, source_p->username, source_p->host,
438                         ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
439 <                       "255.255.255.255" : ipaddr, get_client_class(source_p),
439 >                       "255.255.255.255" : source_p->sockhost,
440 >                       get_client_class(source_p),
441 >                       source_p->info);
442 >
443 >  sendto_realops_flags(UMODE_CCONN_FULL, L_ALL,
444 >                       "CLICONN %s %s %s %s %s %s %s 0 %s",
445 >                       nick, source_p->username, source_p->host,
446 >                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
447 >                       "255.255.255.255" : source_p->sockhost,
448 >                       get_client_class(source_p),
449 >                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
450 >                           "<hidden>" : source_p->client_host,
451 >                       ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
452 >                           "<hidden>" : source_p->client_server,
453                         source_p->info);
454  
455 +
456    /* If they have died in send_* don't do anything. */
457    if (IsDead(source_p))
458      return;
# Line 469 | Line 475 | register_local_user(struct Client *clien
475    SetClient(source_p);
476  
477    source_p->servptr = &me;
478 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
478 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
479  
480    /* Increment our total user count here */
481    if (++Count.total > Count.max_tot)
# Line 559 | Line 565 | register_remote_user(struct Client *clie
565    if (++Count.total > Count.max_tot)
566      Count.max_tot = Count.total;
567  
562  ++source_p->from->serv->dep_users;
563
568    SetClient(source_p);
569 <  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
569 >  dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
570    add_user_host(source_p->username, source_p->host, 1);
571    SetUserHost(source_p);
572  
# Line 589 | Line 593 | introduce_client(struct Client *client_p
593    else
594      send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
595  
596 +  watch_check_hash(source_p, RPL_LOGON);
597 +
598    if (*ubuf == '\0')
599    {
600      ubuf[0] = '+';
601      ubuf[1] = '\0';
602    }
603  
604 <  /* arghhh one could try not introducing new nicks to ll leafs
599 <   * but then you have to introduce them "on the fly" in SJOIN
600 <   * not fun.
601 <   * Its not going to cost much more bandwidth to simply let new
602 <   * nicks just ride on through.
603 <   */
604 <
605 <  /* We now introduce nicks "on the fly" in SJOIN anyway --
606 <   * you _need_ to if you aren't going to burst everyone initially.
607 <   *
608 <   * Only send to non CAP_LL servers, unless we're a lazylink leaf,
609 <   * in that case just send it to the uplink.
610 <   * -davidt
611 <   * rewritten to cope with SIDs .. eww eww eww --is
612 <   */
613 <  if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) &&
614 <      client_p != uplink)
604 >  DLINK_FOREACH(server_node, serv_list.head)
605    {
606 <    if (IsCapable(uplink, CAP_TS6) && HasID(source_p))
607 <    {
608 <      sendto_one(uplink, ":%s UID %s %d %lu %s %s %s %s %s :%s",
606 >    struct Client *server = server_node->data;
607 >
608 >    if (server == client_p)
609 >        continue;
610 >
611 >    if (IsCapable(server, CAP_TS6) && HasID(source_p))
612 >      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
613                   source_p->servptr->id,
614                   source_p->name, source_p->hopcount+1,
615                   (unsigned long)source_p->tsinfo,
616                   ubuf, source_p->username, source_p->host,
617                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
618                   "0" : source_p->sockhost, source_p->id, source_p->info);
625    }
619      else
620 <    {
628 <      sendto_one(uplink, "NICK %s %d %lu %s %s %s %s :%s",
620 >      sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
621                   source_p->name, source_p->hopcount+1,
622                   (unsigned long)source_p->tsinfo,
623                   ubuf, source_p->username, source_p->host,
624                   source_p->servptr->name, source_p->info);
633    }
634  }
635  else
636  {
637    DLINK_FOREACH(server_node, serv_list.head)
638    {
639      struct Client *server = server_node->data;
640
641      if (IsCapable(server, CAP_LL) || server == client_p)
642        continue;
643
644      if (IsCapable(server, CAP_TS6) && HasID(source_p))
645        sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
646                   source_p->servptr->id,
647                   source_p->name, source_p->hopcount+1,
648                   (unsigned long)source_p->tsinfo,
649                   ubuf, source_p->username, source_p->host,
650                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
651                   "0" : source_p->sockhost, source_p->id, source_p->info);
652      else
653        sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
654                   source_p->name, source_p->hopcount+1,
655                   (unsigned long)source_p->tsinfo,
656                   ubuf, source_p->username, source_p->host,
657                   source_p->servptr->name, source_p->info);
658    }
625    }
626   }
627  
# Line 840 | Line 806 | do_local_user(const char *nick, struct C
806  
807    strlcpy(source_p->info, realname, sizeof(source_p->info));
808  
809 +  /* stash for later */
810 +  strlcpy(source_p->client_host, host, sizeof(source_p->client_host));
811 +  strlcpy(source_p->client_server, server, sizeof(source_p->client_server));
812 +
813    if (!IsGotId(source_p))
814    {
815      /* save the username in the client
# Line 861 | Line 831 | do_local_user(const char *nick, struct C
831   static void *
832   change_simple_umode(va_list args)
833   {
834 +  struct Client *client_p;
835    struct Client *source_p;
836    int what;
837    unsigned int flag;
838  
839 <  va_arg(args, struct Client *);
839 >  client_p = va_arg(args, struct Client *);
840    source_p = va_arg(args, struct Client *);
841    what = va_arg(args, int);
842    flag = va_arg(args, unsigned int);
# Line 1051 | Line 1022 | set_user_mode(struct Client *client_p, s
1022   /* send_umode()
1023   * send the MODE string for user (user) to connection client_p
1024   * -avalon
1025 + *
1026 + * inputs       - client_p
1027 + *              - source_p
1028 + *              - int old
1029 + *              - sendmask mask of modes to send
1030 + *              - suplied umode_buf
1031 + * output       - NONE
1032   */
1033   void
1034   send_umode(struct Client *client_p, struct Client *source_p,
# Line 1129 | Line 1107 | send_umode_out(struct Client *client_p,
1107        struct Client *target_p = ptr->data;
1108  
1109        if ((target_p != client_p) && (target_p != source_p))
1110 <      {
1111 <        if ((!(ServerInfo.hub && IsCapable(target_p, CAP_LL))) ||
1112 <            (target_p->localClient->serverMask &
1135 <             source_p->lazyLinkClientExists))
1136 <          sendto_one(target_p, ":%s MODE %s :%s",
1137 <                     ID_or_name(source_p, target_p),
1138 <                     ID_or_name(source_p, target_p), buf);
1139 <      }
1110 >        sendto_one(target_p, ":%s MODE %s :%s",
1111 >                   ID_or_name(source_p, target_p),
1112 >                   ID_or_name(source_p, target_p), buf);
1113      }
1114    }
1115  
# Line 1210 | Line 1183 | user_welcome(struct Client *source_p)
1183   static int
1184   check_xline(struct Client *source_p)
1185   {
1186 <  struct ConfItem *conf;
1187 <  struct MatchItem *xconf;
1215 <  const char *reason;
1186 >  struct ConfItem *conf = NULL;
1187 >  const char *reason = NULL;
1188  
1189 <  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info,
1190 <                                      NULL, NULL, 0)) != NULL)
1189 >  if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) ||
1190 >      (conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1191    {
1192 <    xconf = map_to_conf(conf);
1193 <    xconf->count++;
1192 >    struct MatchItem *reg = map_to_conf(conf);
1193 >
1194 >    ++reg->count;
1195  
1196 <    if (xconf->reason != NULL)
1197 <      reason = xconf->reason;
1196 >    if (reg->reason != NULL)
1197 >      reason = reg->reason;
1198      else
1199        reason = "No Reason";
1200  
# Line 1231 | Line 1204 | check_xline(struct Client *source_p)
1204                           get_client_name(source_p, HIDE_IP),
1205                           source_p->sockhost);
1206  
1207 <    ServerStats->is_ref++;      
1207 >    ++ServerStats.is_ref;
1208      if (REJECT_HOLD_TIME > 0)
1209      {
1210        sendto_one(source_p, ":%s NOTICE %s :Bad user info",
# Line 1247 | Line 1220 | check_xline(struct Client *source_p)
1220    return 0;
1221   }
1222  
1250 static int
1251 check_regexp_xline(struct Client *source_p)
1252 {
1253  struct ConfItem *conf = NULL;
1254  const char *reason = NULL;
1255
1256  if ((conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1257  {
1258    struct MatchItem *reg = map_to_conf(conf);
1259
1260    ++reg->count;
1261
1262    if (reg->reason != NULL)
1263      reason = reg->reason;
1264    else
1265      reason = "No Reason";
1266
1267    sendto_realops_flags(UMODE_REJ, L_ALL,
1268                         "X-line (REGEX) Rejecting [%s] [%s], user %s [%s]",
1269                         source_p->info, reason,
1270                         get_client_name(source_p, HIDE_IP),
1271                         source_p->sockhost);
1272
1273    ServerStats->is_ref++;
1274    exit_client(source_p, &me, "Bad user info");
1275    return 1;
1276  }
1277
1278  return 0;
1279 }
1280
1223   /* oper_up()
1224   *
1225   * inputs       - pointer to given client to oper
# Line 1307 | Line 1249 | oper_up(struct Client *source_p)
1249      source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL|
1250                           UMODE_WALLOP|UMODE_LOCOPS);
1251  
1252 +  if (!(old & UMODE_INVISIBLE) && IsInvisible(source_p))
1253 +    ++Count.invisi;
1254 +  if ((old & UMODE_INVISIBLE) && !IsInvisible(source_p))
1255 +    --Count.invisi;
1256 +
1257    assert(dlinkFind(&oper_list, source_p) == NULL);
1258    dlinkAdd(source_p, make_dlink_node(), &oper_list);
1259  
# Line 1443 | Line 1390 | init_isupport(void)
1390  
1391    add_isupport("CALLERID", NULL, -1);
1392    add_isupport("CASEMAPPING", CASEMAP, -1);
1393 +  add_isupport("DEAF", "D", -1);
1394    add_isupport("KICKLEN", NULL, KICKLEN);
1395    add_isupport("MODES", NULL, MAXMODEPARAMS);
1396    add_isupport("NICKLEN", NULL, NICKLEN-1);

Diff Legend

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