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

Comparing ircd-hybrid/trunk/src/channel_mode.c (file contents):
Revision 8039 by michael, Thu Mar 16 21:03:07 2017 UTC vs.
Revision 8040 by michael, Sat Mar 18 16:20:24 2017 UTC

# Line 58 | Line 58 | const struct mode_letter chan_modes[] =
58    { MODE_REGISTERED, 'r' },
59    { MODE_SECRET,     's' },
60    { MODE_TOPICLIMIT, 't' },
61 +  { MODE_HIDEBMASKS, 'u' },
62    { MODE_NOCTCP,     'C' },
63    { MODE_MODREG,     'M' },
64    { MODE_OPERONLY,   'O' },
# Line 410 | Line 411 | chm_simple(struct Client *source_p, stru
411      mode_changes[mode_count].letter = c;
412      mode_changes[mode_count].arg = NULL;
413      mode_changes[mode_count].id = NULL;
414 +    mode_changes[mode_count].flags = 0;
415      mode_changes[mode_count++].dir = dir;
416    }
417    else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */
# Line 421 | Line 423 | chm_simple(struct Client *source_p, stru
423      mode_changes[mode_count].letter = c;
424      mode_changes[mode_count].arg = NULL;
425      mode_changes[mode_count].id = NULL;
426 +    mode_changes[mode_count].flags = 0;
427      mode_changes[mode_count++].dir = dir;
428    }
429   }
# Line 461 | Line 464 | chm_registered(struct Client *source_p,
464      mode_changes[mode_count].letter = c;
465      mode_changes[mode_count].arg = NULL;
466      mode_changes[mode_count].id = NULL;
467 +    mode_changes[mode_count].flags = 0;
468      mode_changes[mode_count++].dir = dir;
469    }
470    else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */
# Line 472 | Line 476 | chm_registered(struct Client *source_p,
476      mode_changes[mode_count].letter = c;
477      mode_changes[mode_count].arg = NULL;
478      mode_changes[mode_count].id = NULL;
479 +    mode_changes[mode_count].flags = 0;
480      mode_changes[mode_count++].dir = dir;
481    }
482   }
# Line 513 | Line 518 | chm_operonly(struct Client *source_p, st
518      mode_changes[mode_count].letter = c;
519      mode_changes[mode_count].arg = NULL;
520      mode_changes[mode_count].id = NULL;
521 +    mode_changes[mode_count].flags = 0;
522      mode_changes[mode_count++].dir = dir;
523    }
524    else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */
# Line 524 | Line 530 | chm_operonly(struct Client *source_p, st
530      mode_changes[mode_count].letter = c;
531      mode_changes[mode_count].arg = NULL;
532      mode_changes[mode_count].id = NULL;
533 +    mode_changes[mode_count].flags = 0;
534      mode_changes[mode_count++].dir = dir;
535    }
536   }
# Line 544 | Line 551 | chm_ban(struct Client *source_p, struct
551      DLINK_FOREACH(node, chptr->banlist.head)
552      {
553        const struct Ban *ban = node->data;
554 <      sendto_one_numeric(source_p, &me, RPL_BANLIST, chptr->name,
555 <                         ban->name, ban->user, ban->host,
556 <                         ban->who, ban->when);
554 >
555 >      if (!(chptr->mode.mode & MODE_HIDEBMASKS) || alev >= CHACCESS_HALFOP)
556 >        sendto_one_numeric(source_p, &me, RPL_BANLIST, chptr->name,
557 >                           ban->name, ban->user, ban->host,
558 >                           ban->who, ban->when);
559      }
560  
561      sendto_one_numeric(source_p, &me, RPL_ENDOFBANLIST, chptr->name);
# Line 591 | Line 600 | chm_ban(struct Client *source_p, struct
600    mode_changes[mode_count].letter = c;
601    mode_changes[mode_count].arg = mask;  /* At this point 'mask' is no longer than NICKLEN + USERLEN + HOSTLEN + 3 */
602    mode_changes[mode_count].id = NULL;
603 +  if (chptr->mode.mode & MODE_HIDEBMASKS)
604 +    mode_changes[mode_count].flags = CHFL_CHANOP | CHFL_HALFOP;
605 +  else
606 +    mode_changes[mode_count].flags = 0;
607    mode_changes[mode_count++].dir = dir;
608   }
609  
# Line 610 | Line 623 | chm_except(struct Client *source_p, stru
623      DLINK_FOREACH(node, chptr->exceptlist.head)
624      {
625        const struct Ban *ban = node->data;
626 <      sendto_one_numeric(source_p, &me, RPL_EXCEPTLIST, chptr->name,
627 <                         ban->name, ban->user, ban->host,
628 <                         ban->who, ban->when);
626 >
627 >      if (!(chptr->mode.mode & MODE_HIDEBMASKS) || alev >= CHACCESS_HALFOP)
628 >        sendto_one_numeric(source_p, &me, RPL_EXCEPTLIST, chptr->name,
629 >                           ban->name, ban->user, ban->host,
630 >                           ban->who, ban->when);
631      }
632  
633      sendto_one_numeric(source_p, &me, RPL_ENDOFEXCEPTLIST, chptr->name);
# Line 657 | Line 672 | chm_except(struct Client *source_p, stru
672    mode_changes[mode_count].letter = c;
673    mode_changes[mode_count].arg = mask;  /* At this point 'mask' is no longer than NICKLEN + USERLEN + HOSTLEN + 3 */
674    mode_changes[mode_count].id = NULL;
675 +  if (chptr->mode.mode & MODE_HIDEBMASKS)
676 +    mode_changes[mode_count].flags = CHFL_CHANOP | CHFL_HALFOP;
677 +  else
678 +    mode_changes[mode_count].flags = 0;
679    mode_changes[mode_count++].dir = dir;
680   }
681  
# Line 676 | Line 695 | chm_invex(struct Client *source_p, struc
695      DLINK_FOREACH(node, chptr->invexlist.head)
696      {
697        const struct Ban *ban = node->data;
698 <      sendto_one_numeric(source_p, &me, RPL_INVEXLIST, chptr->name,
699 <                         ban->name, ban->user, ban->host,
700 <                         ban->who, ban->when);
698 >
699 >      if (!(chptr->mode.mode & MODE_HIDEBMASKS) || alev >= CHACCESS_HALFOP)
700 >        sendto_one_numeric(source_p, &me, RPL_INVEXLIST, chptr->name,
701 >                           ban->name, ban->user, ban->host,
702 >                           ban->who, ban->when);
703      }
704  
705      sendto_one_numeric(source_p, &me, RPL_ENDOFINVEXLIST, chptr->name);
# Line 723 | Line 744 | chm_invex(struct Client *source_p, struc
744    mode_changes[mode_count].letter = c;
745    mode_changes[mode_count].arg = mask;  /* At this point 'mask' is no longer than NICKLEN + USERLEN + HOSTLEN + 3 */
746    mode_changes[mode_count].id = NULL;
747 +  if (chptr->mode.mode & MODE_HIDEBMASKS)
748 +    mode_changes[mode_count].flags = CHFL_CHANOP | CHFL_HALFOP;
749 +  else
750 +    mode_changes[mode_count].flags = 0;
751    mode_changes[mode_count++].dir = dir;
752   }
753  
# Line 781 | Line 806 | chm_voice(struct Client *source_p, struc
806    mode_changes[mode_count].letter = c;
807    mode_changes[mode_count].arg = target_p->name;
808    mode_changes[mode_count].id = target_p->id;
809 +  mode_changes[mode_count].flags = 0;
810    mode_changes[mode_count++].dir = dir;
811   }
812  
# Line 839 | Line 865 | chm_hop(struct Client *source_p, struct
865    mode_changes[mode_count].letter = c;
866    mode_changes[mode_count].arg = target_p->name;
867    mode_changes[mode_count].id = target_p->id;
868 +  mode_changes[mode_count].flags = 0;
869    mode_changes[mode_count++].dir = dir;
870   }
871  
# Line 897 | Line 924 | chm_op(struct Client *source_p, struct C
924    mode_changes[mode_count].letter = c;
925    mode_changes[mode_count].arg = target_p->name;
926    mode_changes[mode_count].id = target_p->id;
927 +  mode_changes[mode_count].flags = 0;
928    mode_changes[mode_count++].dir = dir;
929   }
930  
# Line 935 | Line 963 | chm_limit(struct Client *source_p, struc
963      mode_changes[mode_count].letter = c;
964      mode_changes[mode_count].arg = lstr;
965      mode_changes[mode_count].id = NULL;
966 +    mode_changes[mode_count].flags = 0;
967      mode_changes[mode_count++].dir = dir;
968  
969      chptr->mode.limit = limit;
# Line 949 | Line 978 | chm_limit(struct Client *source_p, struc
978      mode_changes[mode_count].letter = c;
979      mode_changes[mode_count].arg = NULL;
980      mode_changes[mode_count].id = NULL;
981 +    mode_changes[mode_count].flags = 0;
982      mode_changes[mode_count++].dir = dir;
983    }
984   }
# Line 988 | Line 1018 | chm_key(struct Client *source_p, struct
1018      mode_changes[mode_count].letter = c;
1019      mode_changes[mode_count].arg = key;
1020      mode_changes[mode_count].id = NULL;
1021 +    mode_changes[mode_count].flags = 0;
1022      mode_changes[mode_count++].dir = dir;
1023    }
1024    else if (dir == MODE_DEL)
# Line 1003 | Line 1034 | chm_key(struct Client *source_p, struct
1034      mode_changes[mode_count].letter = c;
1035      mode_changes[mode_count].arg = "*";
1036      mode_changes[mode_count].id = NULL;
1037 +    mode_changes[mode_count].flags = 0;
1038      mode_changes[mode_count++].dir = dir;
1039    }
1040   }
# Line 1126 | Line 1158 | const struct ChannelMode ModeTable[256]
1158    { chm_registered, MODE_REGISTERED },  /* r */
1159    { chm_simple,     MODE_SECRET     },  /* s */
1160    { chm_simple,     MODE_TOPICLIMIT },  /* t */
1161 <  { chm_nosuch,     0               },  /* u */
1161 >  { chm_simple,     MODE_HIDEBMASKS },  /* u */
1162    { chm_voice,      0               },  /* v */
1163    { chm_nosuch,     0               },  /* w */
1164    { chm_nosuch,     0               },  /* x */
# Line 1392 | Line 1424 | send_mode_changes_server(struct Client *
1424   static void
1425   send_mode_changes_client(struct Client *source_p, struct Channel *chptr)
1426   {
1427 <  char modebuf[IRCD_BUFSIZE] = "";
1396 <  char parabuf[IRCD_BUFSIZE] = "";
1397 <  char *parptr = parabuf;
1398 <  int mbl = 0, pbl = 0, arglen = 0, modecount = 0, paracount = 0;
1399 <  int dir = MODE_QUERY;
1400 <
1401 <  if (IsServer(source_p))
1402 <    mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) ||
1403 <                   ConfigServerHide.hide_servers) ?
1404 <                   me.name : source_p->name, chptr->name);
1405 <  else
1406 <    mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name,
1407 <                   source_p->username, source_p->host, chptr->name);
1427 >  unsigned int flags = 0;
1428  
1429 <  for (unsigned int i = 0; i < mode_count; ++i)
1429 >  for (unsigned int pass = 2; pass--; flags = CHFL_CHANOP | CHFL_HALFOP)
1430    {
1431 <    if (mode_changes[i].letter == 0)
1432 <      continue;
1433 <
1434 <    const char *arg = mode_changes[i].arg;
1435 <    if (arg)
1436 <      arglen = strlen(arg);
1431 >    char modebuf[IRCD_BUFSIZE] = "";
1432 >    char parabuf[IRCD_BUFSIZE] = "";
1433 >    char *parptr = parabuf;
1434 >    int mbl = 0, pbl = 0, arglen = 0, modecount = 0, paracount = 0;
1435 >    int dir = MODE_QUERY;
1436 >
1437 >    if (IsServer(source_p))
1438 >      mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) ||
1439 >                     ConfigServerHide.hide_servers) ?
1440 >                     me.name : source_p->name, chptr->name);
1441      else
1442 <      arglen = 0;
1442 >      mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name,
1443 >                     source_p->username, source_p->host, chptr->name);
1444  
1445 <    if ((paracount == MAXMODEPARAMS) ||
1421 <        ((arglen + mbl + pbl + 2 /* +2 for /r/n */ ) > IRCD_BUFSIZE))
1445 >    for (unsigned int i = 0; i < mode_count; ++i)
1446      {
1447 <      if (modecount)
1448 <        sendto_channel_local(NULL, chptr, 0, 0, 0, "%s %s", modebuf, parabuf);
1425 <
1426 <      modecount = 0;
1427 <      paracount = 0;
1447 >      if (mode_changes[i].letter == 0 || mode_changes[i].flags != flags)
1448 >        continue;
1449  
1450 <      if (IsServer(source_p))
1451 <        mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) ||
1452 <                       ConfigServerHide.hide_servers) ?
1432 <                       me.name : source_p->name, chptr->name);
1450 >      const char *arg = mode_changes[i].arg;
1451 >      if (arg)
1452 >        arglen = strlen(arg);
1453        else
1454 <        mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name,
1435 <                       source_p->username, source_p->host, chptr->name);
1454 >        arglen = 0;
1455  
1456 <      pbl = 0;
1457 <      parabuf[0] = '\0';
1458 <      parptr = parabuf;
1459 <      dir = MODE_QUERY;
1456 >      if ((paracount == MAXMODEPARAMS) ||
1457 >          ((arglen + mbl + pbl + 2 /* +2 for /r/n */ ) > IRCD_BUFSIZE))
1458 >      {
1459 >        if (modecount)
1460 >          sendto_channel_local(NULL, chptr, flags, 0, 0, "%s %s", modebuf, parabuf);
1461 >
1462 >        modecount = 0;
1463 >        paracount = 0;
1464 >
1465 >        if (IsServer(source_p))
1466 >          mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) ||
1467 >                         ConfigServerHide.hide_servers) ?
1468 >                         me.name : source_p->name, chptr->name);
1469 >        else
1470 >          mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name,
1471 >                         source_p->username, source_p->host, chptr->name);
1472 >
1473 >        pbl = 0;
1474 >        parabuf[0] = '\0';
1475 >        parptr = parabuf;
1476 >        dir = MODE_QUERY;
1477 >      }
1478 >
1479 >      if (dir != mode_changes[i].dir)
1480 >      {
1481 >        modebuf[mbl++] = (mode_changes[i].dir == MODE_ADD) ? '+' : '-';
1482 >        dir = mode_changes[i].dir;
1483 >      }
1484 >
1485 >      modebuf[mbl++] = mode_changes[i].letter;
1486 >      modebuf[mbl] = '\0';
1487 >      ++modecount;
1488 >
1489 >      if (arg)
1490 >      {
1491 >        int len = sprintf(parptr, (pbl == 0) ? "%s" : " %s", arg);
1492 >        pbl += len;
1493 >        parptr += len;
1494 >        ++paracount;
1495 >      }
1496      }
1497  
1498 <    if (dir != mode_changes[i].dir)
1499 <    {
1445 <      modebuf[mbl++] = (mode_changes[i].dir == MODE_ADD) ? '+' : '-';
1446 <      dir = mode_changes[i].dir;
1447 <    }
1448 <
1449 <    modebuf[mbl++] = mode_changes[i].letter;
1450 <    modebuf[mbl] = '\0';
1451 <    ++modecount;
1452 <
1453 <    if (arg)
1454 <    {
1455 <      int len = sprintf(parptr, (pbl == 0) ? "%s" : " %s", arg);
1456 <      pbl += len;
1457 <      parptr += len;
1458 <      ++paracount;
1459 <    }
1498 >    if (modecount)
1499 >      sendto_channel_local(NULL, chptr, flags, 0, 0, "%s %s", modebuf, parabuf);
1500    }
1461
1462  if (modecount)
1463    sendto_channel_local(NULL, chptr, 0, 0, 0, "%s %s", modebuf, parabuf);
1501   }
1502  
1503   /*

Diff Legend

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