Skip to content
Extraits de code Groupes Projets
Valider 964035b1 rédigé par Tristan Mahé's avatar Tristan Mahé Validation de Eugen Rochko
Parcourir les fichiers

allow localhost to bypass the ratelimit (#2554)

parent 5135d609
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# frozen_string_literal: true # frozen_string_literal: true
class Rack::Attack class Rack::Attack
# Always allow requests from localhost
# (blocklist & throttles are skipped)
Rack::Attack.safelist('allow from localhost') do |req|
# Requests are allowed if the return value is truthy
'127.0.0.1' == req.ip || '::1' == req.ip
end
# Rate limits for the API # Rate limits for the API
throttle('api', limit: 300, period: 5.minutes) do |req| throttle('api', limit: 300, period: 5.minutes) do |req|
req.ip if req.path =~ /\A\/api\/v/ req.ip if req.path =~ /\A\/api\/v/
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter