]> jfr.im git - irc/evilnet/x3.git/commitdiff
Heres an initial version of centralied silence list management, I want to make the...
authorsirvulcan <redacted>
Mon, 22 May 2006 11:42:54 +0000 (11:42 +0000)
committersirvulcan <redacted>
Mon, 22 May 2006 11:42:54 +0000 (11:42 +0000)
ChangeLog
src/chanserv.c
src/nickserv.c
src/nickserv.h
src/nickserv.help
src/proto-p10.c
src/proto.h

index 9492dca4a70a52144707ce2686b86b732f78a8d7..60815b9310426219f4618fb25753e7494bb95ccf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,21 @@
 /***********************************************************************
  X3 ChangeLog
 
-2006-05-16  Neil Spierling  <sirvulcan@gmail.com>
+2006-05-22  Neil Spierling  <sirvulcan@gmail.com>
 
-       * src/proto-p10.c: Changed 050 specfic topic stuff to a conf setting
+       * src/chanserv.c: Set ignores when you authenticate.
 
-       * src/x3.conf.example.: adding 050 'type' to server config (rubin
-       fixed missing ';' and changelog entries)
+       * src/nickserv.c: Added ADDIGNORE, OADDIGNORE, DELIGNORE ODELIGNORE.
+       Used for centralized silence list management. Currently set ignores
+       can be viewed in ACCOUNTINFO for via ircd SILENCE.
+
+       * src/nickserv.h: Declerations.
+
+       * src/nickserv.help: Added help entries for above commands.
+
+       * src/proto.h: Declerations.
+
+       * src/proto-p10.c: Functions to handle silences
 
 2006-05-18  Alex Schumann  <rubin@afternet.org>
 
        * src/mod-track.c: some cleanups and textual changes, to make the commands
        slightly more user friendly.
 
+2006-05-16  Neil Spierling  <sirvulcan@gmail.com>
+
+       * src/proto-p10.c: Changed 050 specfic topic stuff to a conf setting
+
+       * src/x3.conf.example.: adding 050 'type' to server config (rubin
+       fixed missing ';' and changelog entries)
+
 2006-05-16  Neil Spierling  <sirvulcan@gmail.com>
 
        * Most files: Heh i cant be bothered listing all files, see websvn
index dea220e75cf68d8407b0b426fca9406872b8be34..ba9ab9ac6a092c6678c9473af8fec051f90fcb7f 100644 (file)
@@ -7055,7 +7055,7 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
 {
     struct mod_chanmode change;
     struct userData *channel;
-    unsigned int ii, jj;
+    unsigned int ii, jj, i;
 
     if(!user->handle_info)
        return;
@@ -7145,6 +7145,12 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
             }
         }
     }
+
+    if (user->handle_info->ignores->used) {
+        for (i=0; i < user->handle_info->ignores->used; i++) {
+            irc_silence(user, user->handle_info->ignores->list[i], 1);
+        }
+    }
 }
 
 static void
index a9f0732e851ac95c963fd45aa2e91854e4b60575..12e1a30d9e3f7da2e1b929d394f37ae2983b9f23 100644 (file)
@@ -78,6 +78,7 @@
 #define KEY_PASSWD "passwd"
 #define KEY_NICKS "nicks"
 #define KEY_MASKS "masks"
+#define KEY_IGNORES "ignores"
 #define KEY_OPSERV_LEVEL "opserv_level"
 #define KEY_FLAGS "flags"
 #define KEY_REGISTER_ON "register"
@@ -214,6 +215,7 @@ static const struct message_entry msgtab[] = {
     { "NSMSG_HANDLEINFO_LAST_HOST_UNKNOWN", "Last quit hostmask: Unknown" },
     { "NSMSG_HANDLEINFO_NICKS", "Nickname(s): %s" },
     { "NSMSG_HANDLEINFO_MASKS", "Hostmask(s): %s" },
+    { "NSMSG_HANDLEINFO_IGNORES", "Ignore(s): %s" },
     { "NSMSG_HANDLEINFO_CHANNELS", "Channel(s): %s" },
     { "NSMSG_HANDLEINFO_CURRENT", "Current nickname(s): %s" },
     { "NSMSG_HANDLEINFO_DNR", "Do-not-register (by %s): %s" },
@@ -240,6 +242,8 @@ static const struct message_entry msgtab[] = {
     { "NSMSG_MASK_INVALID", "$b%s$b is an invalid hostmask." },
     { "NSMSG_ADDMASK_ALREADY", "$b%s$b is already a hostmask in your account." },
     { "NSMSG_ADDMASK_SUCCESS", "Hostmask %s added." },
+    { "NSMSG_ADDIGNORE_ALREADY", "$b%s$b is already an ignored hostmask in your account." },
+    { "NSMSG_ADDIGNORE_SUCCESS", "Hostmask %s added." },
     { "NSMSG_DELMASK_NOTLAST", "You may not delete your last hostmask." },
     { "NSMSG_DELMASK_SUCCESS", "Hostmask %s deleted." },
     { "NSMSG_DELMASK_NOT_FOUND", "Unable to find mask to be deleted." },
@@ -561,6 +565,7 @@ free_handle_info(void *vhi)
 #endif
 
     free_string_list(hi->masks);
+    free_string_list(hi->ignores);
     assert(!hi->users);
 
     while (hi->nicks)
@@ -1067,6 +1072,7 @@ nickserv_register(struct userNode *user, struct userNode *settee, const char *ha
     cryptpass(passwd, crypted);
     hi = register_handle(handle, crypted, 0);
     hi->masks = alloc_string_list(1);
+    hi->ignores = alloc_string_list(1);
     hi->users = NULL;
     hi->language = lang_C;
     hi->registered = now;
@@ -1442,6 +1448,75 @@ static NICKSERV_FUNC(cmd_oregister)
     return 1;
 }
 
+static int
+nickserv_ignore(struct userNode *user, struct handle_info *hi, const char *mask)
+{
+    unsigned int i;
+    char *new_mask = canonicalize_hostmask(strdup(mask));
+    for (i=0; i<hi->ignores->used; i++) {
+        if (!irccasecmp(new_mask, hi->ignores->list[i])) {
+            send_message(user, nickserv, "NSMSG_ADDIGNORE_ALREADY", new_mask);
+            free(new_mask);
+            return 0;
+        }
+    }
+    string_list_append(hi->ignores, new_mask);
+    send_message(user, nickserv, "NSMSG_ADDIGNORE_SUCCESS", new_mask);
+
+    irc_silence(user, new_mask, 1);
+    return 1;
+}
+
+static NICKSERV_FUNC(cmd_addignore)
+{
+    NICKSERV_MIN_PARMS(2);
+
+    return nickserv_ignore(user, user->handle_info, argv[1]);
+}
+
+static NICKSERV_FUNC(cmd_oaddignore)
+{
+    struct handle_info *hi;
+
+    NICKSERV_MIN_PARMS(3);
+    if (!(hi = get_victim_oper(user, argv[1])))
+        return 0;
+    return nickserv_ignore(user, hi, argv[2]);
+}
+
+static int
+nickserv_delignore(struct userNode *user, struct handle_info *hi, const char *del_mask)
+{
+    unsigned int i;
+    for (i=0; i<hi->ignores->used; i++) {
+       if (!strcmp(del_mask, hi->ignores->list[i])) {
+           char *old_mask = hi->ignores->list[i];
+           hi->ignores->list[i] = hi->ignores->list[--hi->ignores->used];
+           send_message(user, nickserv, "NSMSG_DELMASK_SUCCESS", old_mask);
+            irc_silence(user, old_mask, 0);
+           free(old_mask);
+           return 1;
+       }
+    }
+    send_message(user, nickserv, "NSMSG_DELMASK_NOT_FOUND");
+    return 0;
+}
+
+static NICKSERV_FUNC(cmd_delignore)
+{
+    NICKSERV_MIN_PARMS(2);
+    return nickserv_delignore(user, user->handle_info, argv[1]);
+}
+
+static NICKSERV_FUNC(cmd_odelignore)
+{
+    struct handle_info *hi;
+    NICKSERV_MIN_PARMS(3);
+    if (!(hi = get_victim_oper(user, argv[1])))
+        return 0;
+    return nickserv_delignore(user, hi, argv[2]);
+}
+
 static NICKSERV_FUNC(cmd_handleinfo)
 {
     char buff[400];
@@ -1586,6 +1661,26 @@ static NICKSERV_FUNC(cmd_handleinfo)
         reply("NSMSG_HANDLEINFO_MASKS", nsmsg_none);
     }
 
+    if (hi->ignores->used) {
+        for (i=0; i < hi->ignores->used; i++) {
+            herelen = strlen(hi->ignores->list[i]);
+            if (pos + herelen + 1 > ArrayLength(buff)) {
+                i--;
+                goto print_ignore_buff;
+            }
+            memcpy(buff+pos, hi->ignores->list[i], herelen);
+            pos += herelen; buff[pos++] = ' ';
+            if (i+1 == hi->ignores->used) {
+              print_ignore_buff:
+                buff[pos-1] = 0;
+                reply("NSMSG_HANDLEINFO_IGNORES", buff);
+                pos = 0;
+            }
+        }
+    } else {
+        reply("NSMSG_HANDLEINFO_IGNORES", nsmsg_none);
+    }
+
     if (hi->channels) {
        struct userData *channel, *next;
        char *name;
@@ -3112,6 +3207,8 @@ nickserv_saxdb_write(struct saxdb_context *ctx) {
         saxdb_write_int(ctx, KEY_LAST_SEEN, hi->lastseen);
         if (hi->masks->used)
             saxdb_write_string_list(ctx, KEY_MASKS, hi->masks);
+        if (hi->ignores->used)
+            saxdb_write_string_list(ctx, KEY_IGNORES, hi->ignores);
         if (hi->maxlogins)
             saxdb_write_int(ctx, KEY_MAXLOGINS, hi->maxlogins);
         if (hi->nicks) {
@@ -3139,6 +3236,7 @@ nickserv_saxdb_write(struct saxdb_context *ctx) {
         saxdb_write_string(ctx, KEY_USERLIST_STYLE, flags);
         saxdb_end_record(ctx);
     }
+
     return 0;
 }
 
@@ -3203,6 +3301,16 @@ static NICKSERV_FUNC(cmd_merge)
             string_list_append(hi_to->masks, strdup(mask));
     }
 
+    /* Merge the ignores. */
+    for (ii=0; ii<hi_from->ignores->used; ii++) {
+        char *ignore = hi_from->ignores->list[ii];
+        for (jj=0; jj<hi_to->ignores->used; jj++)
+            if (match_ircglobs(hi_to->ignores->list[jj], ignore))
+                break;
+        if (jj==hi_to->ignores->used) /* Nothing from the "to" handle covered this mask, so add it. */
+            string_list_append(hi_to->ignores, strdup(ignore));
+    }
+
     /* Merge the lists of authed users. */
     if (hi_to->users) {
         for (last_user=hi_to->users; last_user->next_authed; last_user=last_user->next_authed) ;
@@ -3611,7 +3719,7 @@ static void
 nickserv_db_read_handle(const char *handle, dict_t obj)
 {
     const char *str;
-    struct string_list *masks, *slist;
+    struct string_list *masks, *slist, *ignores;
     struct handle_info *hi;
     struct userNode *authed_users;
     struct userData *channels;
@@ -3649,6 +3757,8 @@ nickserv_db_read_handle(const char *handle, dict_t obj)
     hi->channels = channels;
     masks = database_get_data(obj, KEY_MASKS, RECDB_STRING_LIST);
     hi->masks = masks ? string_list_copy(masks) : alloc_string_list(1);
+    ignores = database_get_data(obj, KEY_IGNORES, RECDB_STRING_LIST);
+    hi->ignores = ignores ? string_list_copy(ignores) : alloc_string_list(1);
     str = database_get_data(obj, KEY_MAXLOGINS, RECDB_QSTRING);
     hi->maxlogins = str ? strtoul(str, NULL, 0) : 0;
     str = database_get_data(obj, KEY_LANGUAGE, RECDB_QSTRING);
@@ -4198,6 +4308,7 @@ init_nickserv(const char *nick)
     conf_register_reload(nickserv_conf_read);
     nickserv_opt_dict = dict_new();
     nickserv_email_dict = dict_new();
+
     dict_set_free_keys(nickserv_email_dict, free);
     dict_set_free_data(nickserv_email_dict, nickserv_free_email_addr);
 
@@ -4242,6 +4353,11 @@ init_nickserv(const char *nick)
         dict_insert(nickserv_opt_dict, "EMAIL", opt_email);
     }
     nickserv_define_func("GHOST", cmd_ghost, -1, 1, 0);
+    /* ignore commands */
+    nickserv_define_func("ADDIGNORE", cmd_addignore, -1, 1, 0);
+    nickserv_define_func("OADDIGNORE", cmd_oaddignore, 0, 1, 0);
+    nickserv_define_func("DELIGNORE", cmd_delignore, -1, 1, 0);
+    nickserv_define_func("ODELIGNORE", cmd_odelignore, 0, 1, 0);
     /* miscellaneous commands */
     nickserv_define_func("STATUS", cmd_status, -1, 0, 0);
     nickserv_define_func("SEARCH", cmd_search, 100, 1, 0);
index 68a155ddeae09d92bde4a33b3e313c56de9a5155..69715321c988bc4fa7accdbb3797c600cbcc511c 100644 (file)
@@ -89,6 +89,7 @@ struct handle_note {
 struct handle_info {
     struct nick_info *nicks;
     struct string_list *masks;
+    struct string_list *ignores;
     struct userNode *users;
     struct userData *channels;
     struct handle_cookie *cookie;
index 21f166caaf6f374632dbff814a6279defdd18b8b..affc04308421a7c4cec55bfecb9693d2735c4e6c 100644 (file)
@@ -25,6 +25,7 @@
                 "  $bEMAIL$b        Email based commands",
                 "                 such as recovering forgotten",
                 "                 passwords.",
+                "  $bIGNORE$b       Ignore list management.",
                "  $bINFORMATION$b  Informational functions.",
                 "  $bOPER$b         Commands for IRC Operators.",
                 "$b$b",
@@ -56,6 +57,7 @@
                " $b$N$b help categories:",
                "  $bACCOUNT$b      Account management.",
                "  $bINFORMATION$b  Informational functions.",
+                "  $bIGNORE$b       Ignore list management.",
                 "  $bOPER$b         Commands for IRC Operators.",
                 "$b$b",
                 " $b$N is $uNOT$u a NickServ$b!        ",
                 "*$bOUNREGNICK$b  Remove a nick from someone's account.",
                 " $bOADDMASK$b    Add a mask to someone's account.",
                 " $bODELMASK$b    Remove a mask from someone's account.",
+                " $bOADDIGNORE$b  Add an ignore to someone's account.",
+                " $bODELIGNORE$b  Remove an ignore from someone's account.",
                 " $bMERGEDB$b     Load a database into memory."
         );
 
         "$uSee Also:$u rename"
         );
 };
+
 "MERGEDB" ("/msg $N MERGEDB <dbfilename>",
         "Merge contents of $bdbfilename$b into in-memory database.  Any accounts in both will be $bOVERWRITTEN$b with the information from $bdbfilename$b, although authed users will be authed to the new account.",
         "This command is only accessible to IRC operators.",
         "$uSee Also:$u OperServ.write");
+
+"IGNORE" ("Ignore list management commands are:",
+        " $bADDIGNORE$b   Adds a hostmask to your ignore list.",
+        " $bDELIGNORE$b   Remove an entry from your ignore list.",
+        " $bACCOUNTINFO$b Displays information about an account including ignores.",
+        );
+
+"ADDIGNORE" ("/msg $N ADDIGNORE [user@host]",
+        "Adds the specified user@host to the account ignore list that you are authenticated to with $b$N$b.",
+        "$uSee Also:$u delignore");
+
+"DELIGNORE" ("/msg $N DELIGNORE <user@host>",
+        "Removes a hostmask from the account ignore list that you are authenticated on.",
+        "$uSee Also:$u addignore");
+
+"OADDIGNORE" ("/msg $N OADDIGNORE <nick|*account> <user@host>",
+        "Adds a hostmask to the specified account's ignore list.",
+        "You may use *Account instead of Nick as the name argument; the * makes $N use the name of an account directly (useful if the user is not online).",
+        "$uSee Also:$u odelignore");
+
+"ODELIGNORE" ("/msg $N ODELIGNORE <nick|*account> <user@host>",
+        "Removes a hostmask from the specified account's ignore list.",
+        "You may use *Account instead of Nick as the name argument; the * makes $N use the name of an account directly (useful if the user is not online).",
+        "$uSee Also:$u oaddignore");
index a9731da75b8d1b302f2236b525c8a2afcaee514d..119f48768e18ec46b37928fde02e6987c37c2e75 100644 (file)
@@ -857,6 +857,12 @@ irc_invite(struct userNode *from, struct userNode *who, struct chanNode *to)
     putsock("%s " P10_INVITE " %s %s", from->numeric, who->nick, to->name);
 }
 
+void
+irc_silence(struct userNode *who, const char *mask, int add)
+{
+    putsock("%s " P10_SILENCE " %s %s%s", self->numeric, who->numeric, add ? "" : "-", mask);
+}
+
 void
 irc_join(struct userNode *who, struct chanNode *what)
 {
index fcbc8b03a28eb408e5f9ff6bc44189b9563e2cb7..c892d9bf7b64ddc8d46a8b112c6a260b0e6ed2e7 100644 (file)
@@ -140,6 +140,7 @@ void irc_topic(struct userNode *service, struct userNode *who, struct chanNode *
 void irc_fetchtopic(struct userNode *from, const char *to);
 
 /* network maintenance */
+void irc_silence(struct userNode *who, const char *mask, int add);
 void irc_gline(struct server *srv, struct gline *gline, int silent);
 void irc_shun(struct server *srv, struct shun *shun);
 void irc_settime(const char *srv_name_mask, time_t new_time);