Class: Rack::Protection::IPSpoofing

### Home Classes Methods

### In Files

- lib/rack/protection/ip_spoofing.rb

### Parent

Rack::Protection::Base

### Methods

- #accepts?

### Class/Module Index

Quicksearch

- Rack
- Rack::Protection
- Rack::Protection::AuthenticityToken
- Rack::Protection::Base
- Rack::Protection::EscapedParams
- Rack::Protection::FormToken
- Rack::Protection::FrameOptions
- Rack::Protection::HttpOrigin
- Rack::Protection::IPSpoofing
- Rack::Protection::JsonCsrf
- Rack::Protection::PathTraversal
- Rack::Protection::RemoteReferrer
- Rack::Protection::RemoteToken
- Rack::Protection::SessionHijacking
- Rack::Protection::VERSION
- Rack::Protection::XSSHeader

No matching classes.

# Rack::Protection::IPSpoofing

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

Detect (some) IP spoofing attacks.

### Public Instance Methods

accepts?(env) click to toggle source

    # File lib/rack/protection/ip_spoofing.rb, line 14
    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

[Validate]

Generated with the Darkfish Rdoc Generator 2.