diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-07-19 15:25:22 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-07-19 15:25:22 +0000 |
commit | 455eaba9fcc043cd0e7f497626555af8a5281a2b (patch) | |
tree | 9c9918a05d5456ca00371e1305cffab34d96709e /lib/rbot/ircbot.rb | |
parent | fcfd2064b5de9a33f34e8060194baaa750f01900 (diff) |
Implement byterate-based flood protection
Diffstat (limited to 'lib/rbot/ircbot.rb')
-rw-r--r-- | lib/rbot/ircbot.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 7c95e52e..fb33b7f5 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -78,6 +78,7 @@ class IrcBot # create a new IrcBot with botclass +botclass+ def initialize(botclass, params = {}) # BotConfig for the core bot + # TODO should we split socket stuff into ircsocket, etc? BotConfig.register BotConfigStringValue.new('server.name', :default => "localhost", :requires_restart => true, :desc => "What server should the bot connect to?", @@ -116,8 +117,12 @@ class IrcBot :on_change => Proc.new {|bot, v| bot.socket.sendq_delay = v }) BotConfig.register BotConfigIntegerValue.new('server.sendq_burst', :default => 4, :validate => Proc.new{|v| v >= 0}, - :desc => "(flood prevention) max lines to burst to the server before throttling. Most ircd's allow bursts of up 5 lines, with non-burst limits of 512 bytes/2 seconds", + :desc => "(flood prevention) max lines to burst to the server before throttling. Most ircd's allow bursts of up 5 lines", :on_change => Proc.new {|bot, v| bot.socket.sendq_burst = v }) + BotConfig.register BotConfigStringValue.new('server.byterate', + :default => "400/2", :validate => Proc.new{|v| v.match(/\d+\/\d/)}, + :desc => "(flood prevention) max bytes/seconds rate to send the server. Most ircd's have limits of 512 bytes/2 seconds", + :on_change => Proc.new {|bot, v| bot.socket.byterate = v }) BotConfig.register BotConfigIntegerValue.new('server.ping_timeout', :default => 10, :validate => Proc.new{|v| v >= 0}, :on_change => Proc.new {|bot, v| bot.start_server_pings}, |