Class: Wafris::IpResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/wafris/ip_resolver.rb

Constant Summary collapse

IP_HEADERS =

List of possible IP headers in order of priority

%w[
  HTTP_X_REAL_IP
  HTTP_X_TRUE_CLIENT_IP
  HTTP_FLY_CLIENT_IP
  HTTP_CF_CONNECTING_IP
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ IpResolver

Returns a new instance of IpResolver.



13
14
15
16
# File 'lib/wafris/ip_resolver.rb', line 13

def initialize(request)
  @request_env = request.env
  @ip = request.ip
end

Instance Method Details

#resolveObject



18
19
20
21
22
# File 'lib/wafris/ip_resolver.rb', line 18

def resolve
  return @request_env[ip_header] if ip_header

  @ip
end