implement token bucket rate limiting

This commit is contained in:
Albert Yi
2017-01-06 15:40:49 -08:00
parent 49a72e4bf6
commit f2a5d45db0
20 changed files with 203 additions and 125 deletions

View File

@@ -6,11 +6,11 @@ class IpBan < ActiveRecord::Base
validates_format_of :ip_addr, :with => IP_ADDR_REGEX
validates_uniqueness_of :ip_addr, :if => lambda {|rec| rec.ip_addr =~ IP_ADDR_REGEX}
attr_accessible :ip_addr, :reason
after_create do
ModAction.log("#{CurrentUser.name} created ip ban for #{ip_addr}")
after_create do |rec|
ModAction.log("#{CurrentUser.name} created ip ban for #{rec.ip_addr}")
end
after_destroy do
ModAction.log("#{CurrentUser.name} deleted ip ban for #{ip_addr}")
after_destroy do |rec|
ModAction.log("#{CurrentUser.name} deleted ip ban for ##{rec.ip_addr}")
end
def self.is_banned?(ip_addr)