instance method
sanitize_ips
Ruby on Rails edge
Since v8.1.4 Private — implementation detail, not part of the public APIAvailable in: v8.1.4 edge
Signature
sanitize_ips(ips)
No documentation comment.
Parameters
-
ipsreq
Source
# File actionpack/lib/action_dispatch/middleware/remote_ip.rb, line 184
def sanitize_ips(ips) # :doc:
ips.select! do |ip|
# Only return IPs that are valid according to the IPAddr#new method.
addr = IPAddr.new(ip)
# We want to make sure nobody is sneaking a netmask in, which can only be
# given after a slash.
if ip.include?("/")
range = addr.to_range
next false unless range.begin == range.end
end
# Keep the parsed address for #first_non_proxy, by identity since the
# same strings are checked there.
(@parsed_ips ||= {}.compare_by_identity)[ip] = addr
true
rescue ArgumentError
nil
end
ips
end
Defined in actionpack/lib/action_dispatch/middleware/remote_ip.rb line 184
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::RemoteIp::GetIp