Skip to content

Commit 0100102

Browse files
committed
Revert "Reduce more Array object creations"
This reverts commit cac0e04. Reason: web-console gem expects the existence of `filter_proxy` and overrides this method https://github.com/rails/web-console/blob/v4.2.0/lib/web_console/request.rb#L31-L36
1 parent 4fbc4bb commit 0100102

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

actionpack/lib/action_dispatch/middleware/remote_ip.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def calculate_ip
159159

160160
# If every single IP option is in the trusted list, return the IP
161161
# that's furthest away
162-
ips.detect {|ip| @proxies.none? {|p| p === ip } } || (@proxies.none? {|p| p === remote_addr} && remote_addr) || ips.last || remote_addr
162+
filter_proxies(ips + [remote_addr]).first || ips.last || remote_addr
163163
end
164164

165165
# Memoizes the value returned by #calculate_ip and returns it for
@@ -183,6 +183,12 @@ def ips_from(header) # :doc:
183183
end
184184
ips
185185
end
186+
187+
def filter_proxies(ips) # :doc:
188+
ips.reject do |ip|
189+
@proxies.any? { |proxy| proxy === ip }
190+
end
191+
end
186192
end
187193
end
188194
end

0 commit comments

Comments
 (0)