Permalink
Browse files

:facepalm: Request#remote_ip has to work without the middleware

  • Loading branch information...
1 parent f05ccf8 commit 5621abd5698536f1676306930f6aef105d7ae6dc @indirect indirect committed Nov 16, 2011
@@ -155,9 +155,9 @@ 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"]
+ @remote_ip ||= @env["action_dispatch.remote_ip"] || ip
end
# Returns the unique request id, which is based off either the X-Request-Id header that can
@@ -58,7 +58,7 @@ def calculate_ip
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
+ not_proxy || ips_from('REMOTE_ADDR', :allow_proxies).first
end
def to_s

0 comments on commit 5621abd

Please sign in to comment.