From 7debb7afa7b439d525bf701bafe3a4e6330f950c Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Mon, 27 Apr 2015 12:21:21 -0500 Subject: [PATCH 1/3] Update limits for chat_antiflood_params --- lib/channel/chat.js | 14 +++++++------- lib/channel/opts.js | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/channel/chat.js b/lib/channel/chat.js index 8c10cd61..539a6b97 100644 --- a/lib/channel/chat.js +++ b/lib/channel/chat.js @@ -22,10 +22,10 @@ const TYPE_PM = { meta: "object,optional" }; -const DEFAULT_ANTIFLOOD = { - burst: 4, - sustained: 1, - cooldown: 4 +// Limit to 10 messages/sec +const MIN_ANTIFLOOD = { + burst: 10, + sustained: 10 }; function ChatModule(channel) { @@ -198,8 +198,8 @@ ChatModule.prototype.handlePm = function (user, data) { return; } - if (user.chatLimiter.throttle(DEFAULT_ANTIFLOOD)) { - user.socket.emit("cooldown", 1000 / DEFAULT_ANTIFLOOD.sustained); + if (user.chatLimiter.throttle(MIN_ANTIFLOOD)) { + user.socket.emit("cooldown", 1000 / MIN_ANTIFLOOD.sustained); return; } @@ -255,7 +255,7 @@ ChatModule.prototype.processChatMsg = function (user, data) { } var msgobj = this.formatMessage(user.getName(), data); - var antiflood = DEFAULT_ANTIFLOOD; + var antiflood = MIN_ANTIFLOOD; if (this.channel.modules.options && this.channel.modules.options.get("chat_antiflood")) { diff --git a/lib/channel/opts.js b/lib/channel/opts.js index acdde7a0..45455324 100644 --- a/lib/channel/opts.js +++ b/lib/channel/opts.js @@ -39,6 +39,11 @@ OptionsModule.prototype.load = function (data) { } } } + + this.opts.chat_antiflood_params.burst = Math.min(20, + this.opts.chat_antiflood_params.burst); + this.opts.chat_antiflood_params.sustained = Math.min(10, + this.opts.chat_antiflood_params.sustained); }; OptionsModule.prototype.save = function (data) { @@ -216,11 +221,15 @@ OptionsModule.prototype.handleSetOptions = function (user, data) { b = 1; } + b = Math.min(20, b); + var s = parseFloat(data.chat_antiflood_params.sustained); if (isNaN(s) || s <= 0) { s = 1; } + s = Math.min(10, s); + var c = b / s; this.opts.chat_antiflood_params = { burst: b, From 7782ba4ae519784adda3967da1c38360d3ee8662 Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Mon, 27 Apr 2015 12:22:52 -0500 Subject: [PATCH 2/3] Subject moderators to MIN_ANTIFLOOD rather than channel limit --- lib/channel/chat.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/channel/chat.js b/lib/channel/chat.js index 539a6b97..4b9109d5 100644 --- a/lib/channel/chat.js +++ b/lib/channel/chat.js @@ -257,7 +257,8 @@ ChatModule.prototype.processChatMsg = function (user, data) { var msgobj = this.formatMessage(user.getName(), data); var antiflood = MIN_ANTIFLOOD; if (this.channel.modules.options && - this.channel.modules.options.get("chat_antiflood")) { + this.channel.modules.options.get("chat_antiflood") && + user.account.effectiveRank < 2) { antiflood = this.channel.modules.options.get("chat_antiflood_params"); } From 1ff9f5648b2d85dfa14095818adcfe7059aaff3f Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Mon, 27 Apr 2015 13:09:32 -0500 Subject: [PATCH 3/3] Update MIN_ANTIFLOOD to be the same as the limits for channel settings --- lib/channel/chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/channel/chat.js b/lib/channel/chat.js index 4b9109d5..a6e71b7b 100644 --- a/lib/channel/chat.js +++ b/lib/channel/chat.js @@ -24,7 +24,7 @@ const TYPE_PM = { // Limit to 10 messages/sec const MIN_ANTIFLOOD = { - burst: 10, + burst: 20, sustained: 10 };