mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-25 12:34:58 +01:00
Assign a proc to Rack::Request.ip_filter
instead of patching method (#28380)
This commit is contained in:
parent
db897eaa5a
commit
1ee8d1e50e
@ -1,13 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Rack
|
unless Rails.application.config.action_dispatch.trusted_proxies.nil?
|
||||||
class Request
|
# Rack is configured with a default collection of trusted proxies
|
||||||
def trusted_proxy?(ip)
|
# If Rails has been configured to use a specific list, configure
|
||||||
if Rails.application.config.action_dispatch.trusted_proxies.nil?
|
# Rack to use this Proc, which enforces the Rails-configured list.
|
||||||
super
|
Rack::Request.ip_filter = ->(ip) { Rails.application.config.action_dispatch.trusted_proxies.include?(ip) }
|
||||||
else
|
|
||||||
Rails.application.config.action_dispatch.trusted_proxies.any? { |proxy| proxy === ip }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user