class Rack::Protection::IPSpoofing

Detect (some) IP spoofing attacks.
More infos
blog.c22.cc/2011/04/22/surveymonkey-ip-spoofing/
Supported browsers
all
Prevented attack

IP spoofing
#

def accepts?(env)

def accepts?(env)
  return true unless env.include? 'HTTP_X_FORWARDED_FOR'
  ips = env['HTTP_X_FORWARDED_FOR'].split /\s*,\s*/
  return false if env.include? 'HTTP_CLIENT_IP' and not ips.include? env['HTTP_CLIENT_IP']
  return false if env.include? 'HTTP_X_REAL_IP' and not ips.include? env['HTTP_X_REAL_IP']
  true
end