1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

cleaner names

This commit is contained in:
Andre Arko 2011-11-14 11:20:20 -10:00
parent 9fa329b754
commit 00a0a4ddeb

View file

@ -13,16 +13,16 @@ module ActionDispatch
)\. )\.
}x }x
attr_reader :check_ip_spoofing, :trusted_proxies attr_reader :check_ip, :proxies
def initialize(app, check_ip_spoofing = true, custom_proxies = nil) def initialize(app, check_ip_spoofing = true, custom_proxies = nil)
@app = app @app = app
@check_ip_spoofing = check_ip_spoofing @check_ip = check_ip_spoofing
if custom_proxies if custom_proxies
custom_regexp = Regexp.new(custom_proxies) custom_regexp = Regexp.new(custom_proxies)
@trusted_proxies = Regexp.union(TRUSTED_PROXIES, custom_regexp) @proxies = Regexp.union(TRUSTED_PROXIES, custom_regexp)
else else
@trusted_proxies = TRUSTED_PROXIES @proxies = TRUSTED_PROXIES
end end
end end
@ -47,7 +47,7 @@ module ActionDispatch
forwarded_ips = ips_from('HTTP_X_FORWARDED_FOR') forwarded_ips = ips_from('HTTP_X_FORWARDED_FOR')
remote_addrs = ips_from('REMOTE_ADDR') remote_addrs = ips_from('REMOTE_ADDR')
check_ip = client_ip && @middleware.check_ip_spoofing check_ip = client_ip && @middleware.check_ip
if check_ip && !forwarded_ips.include?(client_ip) if check_ip && !forwarded_ips.include?(client_ip)
# We don't know which came from the proxy, and which from the user # We don't know which came from the proxy, and which from the user
raise IpSpoofAttackError, "IP spoofing attack?!" \ raise IpSpoofAttackError, "IP spoofing attack?!" \
@ -62,7 +62,7 @@ module ActionDispatch
def ips_from(header) def ips_from(header)
ips = @env[header] ? @env[header].strip.split(/[,\s]+/) : [] ips = @env[header] ? @env[header].strip.split(/[,\s]+/) : []
ips.reject{|ip| ip =~ @middleware.trusted_proxies } ips.reject{|ip| ip =~ @middleware.proxies }
end end
end end