]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
Allow /rehash throttles to clear throttling.
authorJilles Tjoelker <redacted>
Sat, 7 Mar 2009 00:49:09 +0000 (01:49 +0100)
committerJilles Tjoelker <redacted>
Sat, 7 Mar 2009 00:49:09 +0000 (01:49 +0100)
include/reject.h
modules/m_rehash.c
src/reject.c

index 95e2c43d4573675f870611fa126f763f0b8fbea4..98cefa944ead6b9e2baa34af5cdf86420dec1451 100644 (file)
@@ -41,6 +41,7 @@ unsigned long delay_exit_length(void);
 int throttle_add(struct sockaddr *addr);
 int is_throttle_ip(struct sockaddr *addr);
 unsigned long throttle_size(void);
+void flush_throttle(void);
 
 
 #endif
index 22848a8c94fd289bc0659d3236a39185efff64bb..4eb4add92b387e196ba85cc35211b9bca0d5e912 100644 (file)
@@ -212,6 +212,15 @@ rehash_rejectcache(struct Client *source_p)
 
 }
 
+static void
+rehash_throttles(struct Client *source_p)
+{
+       sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s is clearing throttles",
+                               get_oper_name(source_p));
+       flush_throttle();
+
+}
+
 static void
 rehash_help(struct Client *source_p)
 {
@@ -252,6 +261,7 @@ static struct hash_commands rehash_commands[] =
        {"TXLINES",     rehash_txlines          },
        {"TRESVS",      rehash_tresvs           },
        {"REJECTCACHE", rehash_rejectcache      },
+       {"THROTTLES",   rehash_throttles        },
        {"HELP",        rehash_help             },
        {"NICKDELAY",   rehash_nickdelay        },
        {NULL,          NULL                    }
index c9c7d455be3c1385577d8b6e0af06f814613a506..3453c7da65bac68dd4f92dcd95d014f4cebb4a23 100644 (file)
@@ -356,6 +356,24 @@ is_throttle_ip(struct sockaddr *addr)
        return 0;
 }
 
+void 
+flush_throttle(void)
+{
+       rb_dlink_node *ptr, *next;
+       rb_patricia_node_t *pnode;
+       throttle_t *t;
+       
+       RB_DLINK_FOREACH_SAFE(ptr, next, throttle_list.head)
+       {
+               pnode = ptr->data;
+               t = pnode->data;                
+
+               rb_dlinkDelete(ptr, &throttle_list);
+               rb_free(t);
+               rb_patricia_remove(throttle_tree, pnode);
+       }
+}
+
 static void
 throttle_expires(void *unused)
 {