Attempt to fix SF bug #2568366 (sending JOIN before hitting a target limit).
authorMichael Poole <mdpoole@troilus.org>
Sat, 4 Jul 2009 22:46:00 +0000 (22:46 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 4 Jul 2009 22:46:00 +0000 (22:46 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1913 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/channel.h
include/gline.h
ircd/channel.c
ircd/ircd_relay.c
ircd/m_wallchops.c
ircd/m_wallvoices.c
ircd/s_user.c
tests/ircd.conf

index ffb41e170f8d43e2a5d95abfaa114e1019e920a7..67592a96a4514fb803d5b3fc92bacfe1b6157081 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-07-04  Michael Poole <mdpoole@troilus.org>
+
+       * include/channel.h (RevealDelayedJoinIfNeeded): Declare.
+
+       * ircd/channel.c (RevealDelayedJoinIfNeeded): Implement.
+
+       * ircd/ircd_relay.c (relay_channel_message): Only reveal the user
+       if he passes the check_target_limit() test.
+       (relay_channel_notice): Likewise.
+
+       * ircd/m_wallchops.c (m_wallchops): Likewise.
+
+       * ircd/m_wallvoices.c (m_wallvoices): Likewise.
+
+       * ircd/s_user.c (check_target_limit): Micro-optimize to only check
+       the user's channel list for invites if we are about to deny it.
+
 2009-03-25  Michael Poole <mdpoole@troilus.org>
 
        * ircd/ircd.c (main): Unconditionally set +6 flag on self.
index 318cf4c124e7e2ac0439437f2a10ef69bc9ae645..7cafdf8d50f8b73a8763a70d59e8bd19eca22826 100644 (file)
@@ -405,6 +405,7 @@ extern char *pretty_mask(char *mask);
 extern void del_invite(struct Client *cptr, struct Channel *chptr);
 extern void list_set_default(void); /* this belongs elsewhere! */
 
+extern void RevealDelayedJoinIfNeeded(struct Client *sptr, struct Channel *chptr);
 extern void RevealDelayedJoin(struct Membership *member);
 extern void CheckDelayedJoins(struct Channel *chan);
 
index 44798a61cd7a29fa19a3b9530599be095cf0863b..f79b801e3cdfee06c11a603d7e7a3a35b650e26a 100644 (file)
@@ -50,13 +50,13 @@ struct Gline {
   struct Gline *gl_next;       /**< Next G-line in linked list. */
   struct Gline**gl_prev_p;     /**< Previous pointer to this G-line. */
   char        *gl_user;        /**< Username mask (or channel/realname mask). */
-  char        *gl_host;        /**< Host prtion of mask. */
+  char        *gl_host;        /**< Host portion of mask. */
   char        *gl_reason;      /**< Reason for G-line. */
   time_t       gl_expire;      /**< Expiration timestamp. */
   time_t       gl_lastmod;     /**< Last modification timestamp. */
   time_t       gl_lifetime;    /**< Record expiration timestamp. */
   struct irc_in_addr gl_addr;  /**< IP address (for IP-based G-lines). */
-  unsigned char gl_bits;       /**< Usable bits in gl_addr. */
+  unsigned char gl_bits;       /**< Bits in gl_addr used in the mask. */
   unsigned int gl_flags;       /**< G-line status flags. */
   enum GlineLocalState gl_state;/**< G-line local state. */
 };
index 471faceb1ef1421416c244e76458faeeaa5f44f9..ee5a887640a00fa4b52eccba786f8e6c6e45b4a2 100644 (file)
@@ -3636,3 +3636,12 @@ void CheckDelayedJoins(struct Channel *chan)
                                      "%H -d", chan);
   }
 }
+
+/** Send a join for the user if (s)he is a hidden member of the channel.
+ */
+void RevealDelayedJoinIfNeeded(struct Client *sptr, struct Channel *chptr)
+{
+  struct Membership *member = find_member_link(chptr, sptr);
+  if (member && IsDelayedJoin(member))
+    RevealDelayedJoin(member);
+}
index 0cb7e80dded0bb8029717f275e92449520f30250..b7a751d7cc4a9446100f904c7c7dd2424867fae3 100644 (file)
@@ -97,7 +97,7 @@ void relay_channel_message(struct Client* sptr, const char* name, const char* te
   /*
    * This first: Almost never a server/service
    */
-  if (!client_can_send_to_channel(sptr, chptr, 1)) {
+  if (!client_can_send_to_channel(sptr, chptr, 0)) {
     send_reply(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname);
     return;
   }
@@ -105,6 +105,7 @@ void relay_channel_message(struct Client* sptr, const char* name, const char* te
       check_target_limit(sptr, chptr, chptr->chname, 0))
     return;
 
+  RevealDelayedJoinIfNeeded(sptr, chptr);
   sendcmdto_channel_butone(sptr, CMD_PRIVATE, chptr, cli_from(sptr),
                           SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text);
 }
@@ -127,13 +128,14 @@ void relay_channel_notice(struct Client* sptr, const char* name, const char* tex
   /*
    * This first: Almost never a server/service
    */
-  if (!client_can_send_to_channel(sptr, chptr, 1))
+  if (!client_can_send_to_channel(sptr, chptr, 0))
     return;
 
   if ((chptr->mode.mode & MODE_NOPRIVMSGS) &&
       check_target_limit(sptr, chptr, chptr->chname, 0))
     return;
 
+  RevealDelayedJoinIfNeeded(sptr, chptr);
   sendcmdto_channel_butone(sptr, CMD_NOTICE, chptr, cli_from(sptr),
                           SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text);
 }
index 5b609590cb48c9651efa612d38c54b5e6e5a2bcf..c57535114656b2d0a85673166cfc83d809a7d536 100644 (file)
@@ -115,10 +115,11 @@ int m_wallchops(struct Client* cptr, struct Client* sptr, int parc, char* parv[]
     return send_reply(sptr, ERR_NOTEXTTOSEND);
 
   if (IsChannelName(parv[1]) && (chptr = FindChannel(parv[1]))) {
-    if (client_can_send_to_channel(sptr, chptr, 1)) {
+    if (client_can_send_to_channel(sptr, chptr, 0)) {
       if ((chptr->mode.mode & MODE_NOPRIVMSGS) &&
           check_target_limit(sptr, chptr, chptr->chname, 0))
         return 0;
+      RevealDelayedJoinIfNeeded(sptr, chptr);
       sendcmdto_channel_butone(sptr, CMD_WALLCHOPS, chptr, cptr,
                               SKIP_DEAF | SKIP_BURST | SKIP_NONOPS,
                               "%H :@ %s", chptr, parv[parc - 1]);
index c5d0461dab54fc7b1ba0e9a733d92543de83b8cb..a0dcd0e65d8feb2fd5379f54acffbb719d1fac41 100644 (file)
@@ -114,10 +114,11 @@ int m_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* parv[
     return send_reply(sptr, ERR_NOTEXTTOSEND);
 
   if (IsChannelName(parv[1]) && (chptr = FindChannel(parv[1]))) {
-    if (client_can_send_to_channel(sptr, chptr, 1)) {
+    if (client_can_send_to_channel(sptr, chptr, 0)) {
       if ((chptr->mode.mode & MODE_NOPRIVMSGS) &&
           check_target_limit(sptr, chptr, chptr->chname, 0))
         return 0;
+      RevealDelayedJoinIfNeeded(sptr, chptr);
       sendcmdto_channel_butone(sptr, CMD_WALLVOICES, chptr, cptr,
                               SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, 
                               "%H :+ %s", chptr, parv[parc - 1]);
index 1fdfcbf323751eaaee06cd4f28479c12ab7971cb..a989a06d00778160d48901cf8c59506261790fd6 100644 (file)
@@ -702,10 +702,6 @@ int check_target_limit(struct Client *sptr, void *target, const char *name,
   assert(cli_local(sptr));
   targets = cli_targets(sptr);
 
-  /* If user is invited to channel, give him/her a free target */
-  if (IsChannelName(name) && IsInvited(sptr, target))
-    return 0;
-
   /*
    * Same target as last time?
    */
@@ -723,6 +719,10 @@ int check_target_limit(struct Client *sptr, void *target, const char *name,
    */
   if (!created) {
     if (CurrentTime < cli_nexttarget(sptr)) {
+      /* If user is invited to channel, give him/her a free target */
+      if (IsChannelName(name) && IsInvited(sptr, target))
+        return 0;
+
       if (cli_nexttarget(sptr) - CurrentTime < TARGET_DELAY + 8) {
         /*
          * No server flooding
index e58c9363af47ef9fb6b37d46e1162e64a14cf956..26f28001bfe0704274e39d53080c2c302aed65ae 100644 (file)
@@ -39,4 +39,5 @@ Features {
         "HUB" = "TRUE";
         "CONFIG_OPERCMDS" = "TRUE";
         "CHANNELLEN" = "50";
+        "MAXCHANNELSPERUSER" = "20";
 };