mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
Add environment variable to allow requests to some private addresses (#14722)
This commit is contained in:
parent
ff89025979
commit
d60290044e
@ -253,7 +253,15 @@ class Request
|
|||||||
alias new open
|
alias new open
|
||||||
|
|
||||||
def check_private_address(address)
|
def check_private_address(address)
|
||||||
raise Mastodon::HostValidationError if PrivateAddressCheck.private_address?(IPAddr.new(address.to_s))
|
addr = IPAddr.new(address.to_s)
|
||||||
|
return if private_address_exceptions.any? { |range| range.include?(addr) }
|
||||||
|
raise Mastodon::HostValidationError if PrivateAddressCheck.private_address?(addr)
|
||||||
|
end
|
||||||
|
|
||||||
|
def private_address_exceptions
|
||||||
|
@private_address_exceptions = begin
|
||||||
|
(ENV['ALLOWED_PRIVATE_ADDRESSES'] || '').split(',').map { |addr| IPAddr.new(addr) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user