Class: XForwardedIPSelector
- Inherits:
-
Object
- Object
- XForwardedIPSelector
- Includes:
- IPSelectorInterface
- Defined in:
- lib/ipinfo-rails/ip_selector/xforwarded_ip_selector.rb
Instance Method Summary collapse
- #get_ip ⇒ Object
-
#initialize(request) ⇒ XForwardedIPSelector
constructor
A new instance of XForwardedIPSelector.
Constructor Details
#initialize(request) ⇒ XForwardedIPSelector
Returns a new instance of XForwardedIPSelector.
7 8 9 |
# File 'lib/ipinfo-rails/ip_selector/xforwarded_ip_selector.rb', line 7 def initialize(request) @request = request end |
Instance Method Details
#get_ip ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/ipinfo-rails/ip_selector/xforwarded_ip_selector.rb', line 11 def get_ip() x_forwarded = @request.env['HTTP_X_FORWARDED_FOR'] if !x_forwarded || x_forwarded.empty? return @request.ip else return x_forwarded.split(',' , -1)[0] end end |