Sha256: 608881f56b23457311eae0f87092d9aaa06f348716a4122c39d464cceededc77

Contents?: true

Size: 817 Bytes

Versions: 9

Compression:

Stored size: 817 Bytes

Contents

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html

require 'sqreen/actions/ip_ranges_index'

module Sqreen
  module Actions
    module IpRangeIndexedActionClass
      include IpRangesIndex

      def actions_matching(client_ip)
        matching_actions client_ip
      end

      def index(params, action)
        ranges = parse_ip_ranges params

        ranges.each do |r|
          add_prefix r, action
        end
      end

      private

      # returns array of prefixes in string form
      def parse_ip_ranges(params)
        ranges = params['ip_cidr']
        unless ranges && ranges.is_a?(Array) && !ranges.empty?
          raise 'no non-empty ip_cidr array present'
        end

        ranges
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sqreen-1.18.6-java lib/sqreen/actions/ip_range_indexed_action_class.rb
sqreen-1.18.6 lib/sqreen/actions/ip_range_indexed_action_class.rb
sqreen-1.18.5-java lib/sqreen/actions/ip_range_indexed_action_class.rb
sqreen-1.18.5 lib/sqreen/actions/ip_range_indexed_action_class.rb
sqreen-1.18.4-java lib/sqreen/actions/ip_range_indexed_action_class.rb
sqreen-1.18.4 lib/sqreen/actions/ip_range_indexed_action_class.rb
sqreen-1.18.3-java lib/sqreen/actions/ip_range_indexed_action_class.rb
sqreen-1.18.3 lib/sqreen/actions/ip_range_indexed_action_class.rb
sqreen-1.18.3.beta2 lib/sqreen/actions/ip_range_indexed_action_class.rb