Move `ALLOWED_PRIVATE_ADDRESSES` parsing to an initializer (#32850)
parent
32e5e1d3f1
commit
f5f6273d2b
|
@ -334,14 +334,10 @@ class Request
|
||||||
def check_private_address(address, host)
|
def check_private_address(address, host)
|
||||||
addr = IPAddr.new(address.to_s)
|
addr = IPAddr.new(address.to_s)
|
||||||
|
|
||||||
return if Rails.env.development? || private_address_exceptions.any? { |range| range.include?(addr) }
|
return if Rails.env.development? || Rails.configuration.x.private_address_exceptions.any? { |range| range.include?(addr) }
|
||||||
|
|
||||||
raise Mastodon::PrivateNetworkAddressError, host if PrivateAddressCheck.private_address?(addr)
|
raise Mastodon::PrivateNetworkAddressError, host if PrivateAddressCheck.private_address?(addr)
|
||||||
end
|
end
|
||||||
|
|
||||||
def private_address_exceptions
|
|
||||||
@private_address_exceptions = (ENV['ALLOWED_PRIVATE_ADDRESSES'] || '').split(/(?:\s*,\s*|\s+)/).map { |addr| IPAddr.new(addr) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
Rails.application.configure do
|
||||||
|
config.x.private_address_exceptions = (ENV['ALLOWED_PRIVATE_ADDRESSES'] || '').split(/(?:\s*,\s*|\s+)/).map { |addr| IPAddr.new(addr) }
|
||||||
|
end
|
Loading…
Reference in New Issue