mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 22:15:23 +01:00
Move ALLOWED_PRIVATE_ADDRESSES
parsing to an initializer (#32850)
This commit is contained in:
parent
32e5e1d3f1
commit
f5f6273d2b
2 changed files with 6 additions and 5 deletions
|
@ -334,14 +334,10 @@ class Request
|
|||
def check_private_address(address, host)
|
||||
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)
|
||||
end
|
||||
|
||||
def private_address_exceptions
|
||||
@private_address_exceptions = (ENV['ALLOWED_PRIVATE_ADDRESSES'] || '').split(/(?:\s*,\s*|\s+)/).map { |addr| IPAddr.new(addr) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
5
config/initializers/allowed_private_addresses.rb
Normal file
5
config/initializers/allowed_private_addresses.rb
Normal file
|
@ -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 a new issue