Sha256: c490ddec5d354af7ecfa1876e0bb1edfba6c46866a24385d4151e140aa4227c4
Contents?: true
Size: 1.89 KB
Versions: 3
Compression:
Stored size: 1.89 KB
Contents
# # Ronin Web - A Ruby library for Ronin that provides support for web # scraping and spidering functionality. # # Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com) # # This file is part of Ronin Web. # # Ronin is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ronin is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ronin. If not, see <http://www.gnu.org/licenses/>. # require 'ipaddr' module Ronin module Web module Middleware module Filters # # A Filter to match requests based on their IP Address. # class IPFilter # # Creates a new IP filter. # # @param [String, IPAddr] ip # The IP Address to match against. # # @since 0.3.0 # # @api private # def initialize(ip) @ip = unless ip.kind_of?(IPAddr) IPAddr.new(ip.to_s) else ip end end # # Matches the filter against the request. # # @param [Rack::Request] request # The incoming request. # # @return [Boolean] # Specifies whether the filter matched the request. # # @since 0.3.0 # # @api private # def match?(request) @ip.include?(request.ip) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems