Method: PxModule::PerimeterXContext.extract_ip

Defined in:
lib/perimeterx/internal/perimeter_x_context.rb

.extract_ip(req, px_config) ⇒ Object

class methods



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/perimeterx/internal/perimeter_x_context.rb', line 12

def self.extract_ip(req, px_config)
  # Get IP from header/custom function
  if px_config[:ip_headers].length() > 0
    px_config[:ip_headers].each do |ip_header|
      if req.headers[ip_header]
        return PerimeterXContext.force_utf8(req.headers[ip_header])
      end
    end
  elsif px_config[:ip_header_function] != nil
    return px_config[:ip_header_function].call(req) 
  end      
  return req.ip
end