123456789_123456789_123456789_123456789_123456789_

Class: Rack::Protection::IPSpoofing

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: Rack::Protection::Base
Defined in: rack-protection/lib/rack/protection/ip_spoofing.rb

Overview

Prevented attack:: IP spoofing Supported browsers:: all More infos:: http://blog.c22.cc/2011/04/22/surveymonkey-ip-spoofing/

Detect (some) IP spoofing attacks.

Constant Summary

Base - Inherited

DEFAULT_OPTIONS

Class Method Summary

Instance Attribute Summary

Base - Inherited

Instance Method Summary

Constructor Details

This class inherits a constructor from Rack::Protection::Base

Instance Method Details

#accepts?(env) ⇒ Boolean

[ GitHub ]

  
# File 'rack-protection/lib/rack/protection/ip_spoofing.rb', line 16

def accepts?(env)
  return true unless env.include? 'HTTP_X_FORWARDED_FOR'

  ips = env['HTTP_X_FORWARDED_FOR'].split(',').map(&:strip)
  return false if env.include?('HTTP_CLIENT_IP') && (!ips.include? env['HTTP_CLIENT_IP'])
  return false if env.include?('HTTP_X_REAL_IP') && (!ips.include? env['HTTP_X_REAL_IP'])

  true
end