File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 11class Rack ::Attack
2- # 10 requests per 10 seconds for a single ip
3- throttle ( 'req/ip' , limit : 10 , period : 10 ) do |req |
4- req . ip
5- end
6-
72 # response with 429
83 self . throttled_response = -> ( env ) {
94 retry_after = ( env [ 'rack.attack.match_data' ] || { } ) [ :period ]
@@ -13,9 +8,14 @@ class Rack::Attack
138 [ { error : "Throttle limit reached. Retry later." } . to_json ]
149 ]
1510 }
11+ end
12+
13+ # 10 requests per 10 seconds for a single ip
14+ Rack ::Attack ::throttle ( 'req/ip' , limit : 10 , period : 10 ) do |req |
15+ req . ip
16+ end
1617
17- # whitelist localhost
18- safelist ( 'allow-localhost' ) do |req |
19- '127.0.0.1' == req . ip || '::1' == req . ip
20- end
18+ # whitelist localhost
19+ Rack ::Attack ::safelist ( 'allow-localhost' ) do |req |
20+ '127.0.0.1' == req . ip || '::1' == req . ip
2121end
You can’t perform that action at this time.
0 commit comments