Skip to content

Commit

Permalink
Add environment variable to allow requests to some private addresses (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and thenameisnigel-old committed Sep 28, 2020
1 parent 5d616cf commit c10e7a0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/lib/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,15 @@ def open(host, *args)
alias new open

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
Expand Down

0 comments on commit c10e7a0

Please sign in to comment.