notsofast 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/notsofast/rate_limit.rb +0 -5
- data/lib/notsofast/version.rb +1 -1
- metadata +1 -1
data/lib/notsofast/rate_limit.rb
CHANGED
@@ -19,14 +19,12 @@ module Notsofast
|
|
19
19
|
status, headers, response = @app.call(env)
|
20
20
|
|
21
21
|
if timestamp - @connections_timestamp > Notsofast::Config.limit_expiry
|
22
|
-
puts "clearing connections cache"
|
23
22
|
@connections_timestamp = timestamp
|
24
23
|
@connections = {}
|
25
24
|
end
|
26
25
|
|
27
26
|
ip_address = remote_ip(env)
|
28
27
|
|
29
|
-
puts Notsofast::Config.whitelist.include?(ip_address)
|
30
28
|
unless Notsofast::Config.whitelist.include?(ip_address)
|
31
29
|
if Notsofast::Config.blacklist.include?(ip_address)
|
32
30
|
response = Rack::Response.new
|
@@ -35,15 +33,12 @@ module Notsofast
|
|
35
33
|
response.finish
|
36
34
|
return
|
37
35
|
else
|
38
|
-
puts "checking the content "
|
39
36
|
if (headers["Content-Type"].nil? && Notsofast::Config.response_types.empty?) || (headers["Content-Type"].present? && Notsofast::Config.response_types.present? && Notsofast::Config.response_types.select{|r| headers["Content-Type"].include?(r)}.count > 0)
|
40
|
-
puts "matched content type"
|
41
37
|
if @connections[ip_address]
|
42
38
|
@connections[ip_address] += 1
|
43
39
|
else
|
44
40
|
@connections[ip_address] = 1
|
45
41
|
end
|
46
|
-
puts @connections
|
47
42
|
|
48
43
|
if @connections[ip_address] > Notsofast::Config.request_limit
|
49
44
|
response = Rack::Response.new
|
data/lib/notsofast/version.rb
CHANGED