instance method
check_ip
Ruby on Rails edge
Since v8.1.4.1 Private — implementation detail, not part of the public APIAvailable in: v8.1.4.1 edge
Signature
check_ip(client_ips, forwarded_ips)
No documentation comment.
Parameters
-
client_ipsreq -
forwarded_ipsreq
Source
# File actionpack/lib/action_dispatch/middleware/remote_ip.rb, line 196
def check_ip(client_ips, forwarded_ips)
if client_ips.last && forwarded_ips.last && !forwarded_ips.include?(client_ips.last)
# We don't know which came from the proxy, and which from the user
raise_spoofing_error
end
if @req.get_header("HTTP_FORWARDED") && @req.x_forwarded_for
x_forwarded_ips = XForwardedForParser.new("HTTP_X_FORWARDED_FOR" => @req.x_forwarded_for).forwarded_for || []
x_forwarded_client = first_non_proxy(sanitize_ips(x_forwarded_ips).reverse!)
forwarded_client = first_non_proxy(forwarded_ips)
# Compare strings, not parsed addresses, so the client cannot choose how its
# own address is spelled.
if x_forwarded_client && x_forwarded_client != forwarded_client
raise_spoofing_error
end
end
end
Defined in actionpack/lib/action_dispatch/middleware/remote_ip.rb line 196
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::RemoteIp::GetIp