Support MODE +d
authorJelmer Vernooij <jelmer@samba.org>
Thu, 1 May 2008 01:15:15 +0000 (03:15 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 1 May 2008 01:15:15 +0000 (03:15 +0200)
NEWS
lib/state.c
lib/state.h

diff --git a/NEWS b/NEWS
index 675b2c7ee46b0b9391cd0bf56175fe534f99320c..1e9617ff5a0f1275ea50ed8461ad4e95cf54e454 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,7 +17,8 @@ Ctrlproxy 3.0.7 UNRELEASED
 
     * Move time in ctcp requests. (#197)
 
-    * Support storing exception lists.
+    * Support storing exception lists and realname ban lists (MODE +e and MODE +d)
+      as supported by hyperion.
 
        * Fix handling of channel and user modes. (#196)
 
index 1ab6b99f9d258f95c76505e68db80e70bebf5c19..b8e3600fbb91961cae5050148e8cda26556d8e7f 100644 (file)
@@ -174,6 +174,16 @@ static char *find_exceptlist_entry(GList *entries, const char *entry)
        return NULL;
 }
 
+static char *find_realnamebanlist_entry(GList *entries, const char *entry)
+{
+       GList *gl;
+       for (gl = entries; gl; gl = gl->next) {
+               if (!strcmp(gl->data, entry))
+                       return gl->data;
+       }
+       return NULL;
+}
+
 static struct banlist_entry *find_banlist_entry(GList *entries, const char *hostmask)
 {
        GList *gl;
@@ -868,15 +878,33 @@ static int channel_state_change_mode(struct irc_network_state *s, struct network
                if (set) {
                        c->exceptlist = g_list_append(c->exceptlist, g_strdup(opt_arg));
                } else {
-                       char *be = find_exceptlist_entry(c->banlist, opt_arg);
+                       char *be = find_exceptlist_entry(c->exceptlist, opt_arg);
                        if (be == NULL) {
                                network_state_log(LOG_WARNING, s, "Unable to remove nonpresent ban except list entry '%s'", opt_arg);
                                return 1;
                        }
-                       c->banlist = g_list_remove(c->exceptlist, be);
+                       c->exceptlist = g_list_remove(c->exceptlist, be);
                        g_free(be);
                }
                return 1;
+       } else if (mode == 'd') { /* Realname ban */
+               if (opt_arg == NULL) {
+                       network_state_log(LOG_WARNING, s, "Missing argument for realname ban MODE set/unset");
+                       return -1;
+               }
+
+               if (set) {
+                       c->realnamebanlist = g_list_append(c->realnamebanlist, g_strdup(opt_arg));
+               } else {
+                       char *be = find_realnamebanlist_entry(c->realnamebanlist, opt_arg);
+                       if (be == NULL) {
+                               network_state_log(LOG_WARNING, s, "Unable to remove nonpresent realname ban list entry '%s'", opt_arg);
+                               return 1;
+                       }
+                       c->realnamebanlist = g_list_remove(c->realnamebanlist, be);
+                       g_free(be);
+               }
+               return 1;       
        } else if (mode == 'l') { /* Limit */
                modes_change_mode(c->modes, set, 'l');
                if (set) {
index ea472f3c511a8d4ad19c45ef817ed94dafea0aaf..c6d83434e4168949260b5f2c6e2119463c0eb806 100644 (file)
@@ -97,6 +97,7 @@ struct irc_channel_state {
        GList *banlist;
        GList *invitelist;
        GList *exceptlist;
+       GList *realnamebanlist;
        struct irc_network_state *network;
 };