diff options
author | Timo Sirainen <cras@irssi.org> | 2000-06-14 17:52:03 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-06-14 17:52:03 +0000 |
commit | 47fd84c5bc3306b946c253afda633d7cbc61a8a6 (patch) | |
tree | 5cc2280a7682659ebd8cfa270d3453526f904cef | |
parent | 6d77cdc8b70bc6ac322f06db075b36f36b0639cf (diff) | |
download | irssi-47fd84c5bc3306b946c253afda633d7cbc61a8a6.zip |
Fixed some flood detection, ignoring and autoignoring bugs.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@339 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | src/fe-common/irc/fe-ignore.c | 2 | ||||
-rw-r--r-- | src/fe-common/irc/flood/module-formats.c | 2 | ||||
-rw-r--r-- | src/irc/core/ignore.c | 5 | ||||
-rw-r--r-- | src/irc/flood/autoignore.c | 30 | ||||
-rw-r--r-- | src/irc/flood/flood.c | 13 |
5 files changed, 41 insertions, 11 deletions
diff --git a/src/fe-common/irc/fe-ignore.c b/src/fe-common/irc/fe-ignore.c index 989d91cd..cbd74244 100644 --- a/src/fe-common/irc/fe-ignore.c +++ b/src/fe-common/irc/fe-ignore.c @@ -155,7 +155,7 @@ static void cmd_ignore(const char *data) args = "pattern channels"; params = cmd_get_params(data, 5 | PARAM_FLAG_MULTIARGS | PARAM_FLAG_GETREST, &args, &patternarg, &chanarg, &mask, &levels); - if (levels == 0) cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + if (*levels == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (ischannel(*mask)) { chanarg = mask; diff --git a/src/fe-common/irc/flood/module-formats.c b/src/fe-common/irc/flood/module-formats.c index 2d0293bc..e591d42c 100644 --- a/src/fe-common/irc/flood/module-formats.c +++ b/src/fe-common/irc/flood/module-formats.c @@ -29,7 +29,7 @@ FORMAT_REC fecommon_irc_flood_formats[] = { NULL, "Autoignore", 0 }, { "autoignore", "Flood detected from %_$0%_, autoignoring for %_$1%_ minutes", 2, { 0, 1 } }, - { "autounignore", "Unignoring %_$0", 1, { 0 } }, + { "autounignore", "Removed autoignore from %_$0", 1, { 0 } }, { NULL, NULL, 0 } }; diff --git a/src/irc/core/ignore.c b/src/irc/core/ignore.c index b1b9aa1a..d0336bb4 100644 --- a/src/irc/core/ignore.c +++ b/src/irc/core/ignore.c @@ -248,11 +248,14 @@ void ignore_add_rec(IGNORE_REC *rec) { ignores = g_slist_append(ignores, rec); ignore_set_config(rec); + + signal_emit("ignore created", 1, rec); } static void ignore_destroy(IGNORE_REC *rec) { ignores = g_slist_remove(ignores, rec); + signal_emit("ignore destroyed", 1, rec); if (rec->channels != NULL) g_strfreev(rec->channels); g_free_not_null(rec->mask); @@ -274,6 +277,8 @@ void ignore_update_rec(IGNORE_REC *rec) ignores = g_slist_append(ignores, rec); ignore_set_config(rec); + + signal_emit("ignore changed", 1, rec); } } diff --git a/src/irc/flood/autoignore.c b/src/irc/flood/autoignore.c index 1b3f757f..3df4228d 100644 --- a/src/irc/flood/autoignore.c +++ b/src/irc/flood/autoignore.c @@ -230,6 +230,32 @@ static void sig_flood(IRC_SERVER_REC *server, const char *nick, const char *host autoignore_add(server, nick, level); } +static void autoignore_remove_level(const char *nick, int level) +{ + AUTOIGNORE_REC *rec; + GSList *tmp; + + for (tmp = servers; tmp != NULL; tmp = tmp->next) { + IRC_SERVER_REC *server = tmp->data; + + rec = autoignore_find(server, nick); + if (rec != NULL && (rec->level & level)) { + rec->level &= ~level; + if (rec->level == 0) autoignore_remove_rec(server, rec); + } + } +} + +static void sig_ignore_destroyed(IGNORE_REC *ignore) +{ + autoignore_remove_level(ignore->mask, MSGLEVEL_ALL); +} + +static void sig_ignore_changed(IGNORE_REC *ignore) +{ + autoignore_remove_level(ignore->mask, ~ignore->level); +} + void autoignore_init(void) { settings_add_int("flood", "autoignore_time", 300); @@ -240,6 +266,8 @@ void autoignore_init(void) signal_add("server connected", (SIGNAL_FUNC) autoignore_init_server); signal_add("server disconnected", (SIGNAL_FUNC) autoignore_deinit_server); signal_add("flood", (SIGNAL_FUNC) sig_flood); + signal_add("ignore destroyed", (SIGNAL_FUNC) sig_ignore_destroyed); + signal_add("ignore changed", (SIGNAL_FUNC) sig_ignore_changed); } void autoignore_deinit(void) @@ -249,4 +277,6 @@ void autoignore_deinit(void) signal_remove("server connected", (SIGNAL_FUNC) autoignore_init_server); signal_remove("server disconnected", (SIGNAL_FUNC) autoignore_deinit_server); signal_remove("flood", (SIGNAL_FUNC) sig_flood); + signal_remove("ignore destroyed", (SIGNAL_FUNC) sig_ignore_destroyed); + signal_remove("ignore changed", (SIGNAL_FUNC) sig_ignore_changed); } diff --git a/src/irc/flood/flood.c b/src/irc/flood/flood.c index 0466d769..b1096359 100644 --- a/src/irc/flood/flood.c +++ b/src/irc/flood/flood.c @@ -167,6 +167,7 @@ static void flood_newmsg(IRC_SERVER_REC *server, int level, const char *nick, co if (rec != NULL) { if (++rec->msgcount > flood_max_msgs) { /* flooding! */ + rec->first = 0; signal_emit("flood", 5, server, nick, host, GINT_TO_POINTER(rec->level), target); } return; @@ -242,22 +243,16 @@ static void flood_ctcp(const char *data, IRC_SERVER_REC *server, const char *nic static void read_settings(void) { - int time; - flood_timecheck = settings_get_int("flood_timecheck"); flood_max_msgs = settings_get_int("flood_max_msgs"); - time = flood_timecheck > 500 ? 500 : - (flood_timecheck > 0 && flood_timecheck < 100) ? 100 : - flood_timecheck; - if (flood_tag != -1) { g_source_remove(flood_tag); flood_tag = -1; } if (time > 0 && flood_max_msgs > 0) { - flood_tag = g_timeout_add(time, (GSourceFunc) flood_timeout, NULL); + flood_tag = g_timeout_add(500, (GSourceFunc) flood_timeout, NULL); signal_add("event privmsg", (SIGNAL_FUNC) flood_privmsg); signal_add("event notice", (SIGNAL_FUNC) flood_notice); signal_add("ctcp msg", (SIGNAL_FUNC) flood_ctcp); @@ -267,8 +262,8 @@ static void read_settings(void) void irc_flood_init(void) { - settings_add_int("flood", "flood_timecheck", 8000); - settings_add_int("flood", "flood_max_msgs", 5); + settings_add_int("flood", "flood_timecheck", 8); + settings_add_int("flood", "flood_max_msgs", 4); flood_tag = -1; read_settings(); |