Class: WebConsole::Request::GetSecureIp
- Inherits:
-
ActionDispatch::RemoteIp::GetIp
- Object
- ActionDispatch::RemoteIp::GetIp
- WebConsole::Request::GetSecureIp
- Defined in:
- lib/web_console/request.rb
Instance Method Summary collapse
-
#filter_proxies(ips) ⇒ Object
Used by rails <= 8.1.
-
#first_non_proxy(ips) ⇒ Object
Used by rails > 8.1.
-
#initialize(req, proxies) ⇒ GetSecureIp
constructor
A new instance of GetSecureIp.
Constructor Details
#initialize(req, proxies) ⇒ GetSecureIp
Returns a new instance of GetSecureIp.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/web_console/request.rb', line 20 def initialize(req, proxies) # After rails/rails@07b2ff0 ActionDispatch::RemoteIp::GetIp initializes # with a ActionDispatch::Request object instead of plain Rack # environment hash. Keep both @req and @env here, so we don't if/else # on Rails versions. @req = req @env = req.env @check_ip = true @proxies = proxies end |
Instance Method Details
#filter_proxies(ips) ⇒ Object
Used by rails <= 8.1
32 33 34 35 36 |
# File 'lib/web_console/request.rb', line 32 def filter_proxies(ips) ips.reject do |ip| @proxies.include?(ip) end end |
#first_non_proxy(ips) ⇒ Object
Used by rails > 8.1.
39 40 41 42 43 |
# File 'lib/web_console/request.rb', line 39 def first_non_proxy(ips) ips.find do |ip| !@proxies.include?(ip) end end |