lib/wmap/cidr_tracker.rb
# Check if the specific IP within the range of a list of known CIDR blocks
Check if the specific IP within the range of a list of known CIDR blocks
Check if the specific IP within the range of a list of known CIDR blocks
def ip_trusted? (ip)
		puts "Check if the IP within the range of the known CIDR blocks: #{ip}" if @verbose
		known = false
		return false if @known_cidr_blks==nil
		first_octet_ip = ip.split('.').first.to_i
		@known_cidr_blks_desc_index.each do |line|
			first_octet_blk = line.split('.').first.to_i
			next if first_octet_blk > first_octet_ip
			puts "line: #{line}" if @verbose
			cidr4 = NetAddr::CIDR.create(line)
			known = cidr4.contains?(ip+'/32')
			break if known
		end
		return known
	rescue => ee
		puts "Exception on method #{__method__}: #{ee}" if @verbose
		return false
	end
def ip_trusted? ( ip ) puts "Check if the IP within the range of the known CIDR blocks: #{ip}" if @verbose known = false return false if @known_cidr_blks == nil first_octet_ip = ip . split ( '.' ) . first . to_i @known_cidr_blks_desc_index . each do | line | first_octet_blk = line . split ( '.' ) . first . to_i next if first_octet_blk > first_octet_ip puts "line: #{line}" if @verbose cidr4 = NetAddr :: CIDR . create ( line ) known = cidr4 . contains? ( ip + '/32' ) break if known end return known rescue => ee puts "Exception on method #{__method__}: #{ee}" if @verbose return false end
Check if the specific IP within the range of a list of known CIDR blocks
Check if the specific IP within the range of a list of known CIDR blocks
ip
<not_specific>