Revert "Merge pull request #3640 from indirect/remote_ip"
This reverts commit 6491aadc525b8703708e0fd0fbf05bd436a47801, reversing changes made to 83bf0b626cf2134260903e57d74f67de57384073. See https://github.com/rails/rails/pull/3640#issuecomment-2752761 for explanation.
This commit is contained in:
parent
6491aadc52
commit
8d1a2b3ecd
@ -155,9 +155,10 @@ def ip
|
||||
@ip ||= super
|
||||
end
|
||||
|
||||
# Originating IP address from the RemoteIp middleware.
|
||||
# Originating IP address, usually set by the RemoteIp middleware.
|
||||
def remote_ip
|
||||
@remote_ip ||= @env["action_dispatch.remote_ip"]
|
||||
# Coerce the remote_ip object into a string, because to_s could return nil
|
||||
@remote_ip ||= @env["action_dispatch.remote_ip"].to_s || ip
|
||||
end
|
||||
|
||||
# Returns the unique request id, which is based off either the X-Request-Id header that can
|
||||
|
@ -55,10 +55,7 @@ def calculate_ip
|
||||
"HTTP_X_FORWARDED_FOR=#{@env['HTTP_X_FORWARDED_FOR'].inspect}"
|
||||
end
|
||||
|
||||
not_proxy = client_ip || forwarded_ips.last || remote_addrs.first
|
||||
|
||||
# Return first REMOTE_ADDR if there are no other options
|
||||
not_proxy || ips_from('REMOTE_ADDR', :all).first
|
||||
client_ip || forwarded_ips.last || remote_addrs.first
|
||||
end
|
||||
|
||||
def to_s
|
||||
@ -69,9 +66,9 @@ def to_s
|
||||
|
||||
protected
|
||||
|
||||
def ips_from(header, allow_proxies = false)
|
||||
def ips_from(header)
|
||||
ips = @env[header] ? @env[header].strip.split(/[,\s]+/) : []
|
||||
allow_proxies ? ips : ips.reject{|ip| ip =~ @middleware.proxies }
|
||||
ips.reject{|ip| ip =~ @middleware.proxies }
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user