lib/wmap/cidr_tracker.rb
# 'setter' to load the known CIDR blocks into an instance variable @known_cidr_blks
'setter' to load the known CIDR blocks into an instance variable @known_cidr_blks
' setter ' to load the known CIDR blocks into an instance variable @known_cidr_blks
def load_cidr_blks_from_file(file_cidrs=@cidr_seeds)
		puts "Load the known CIDR seed file: #{file_cidrs}" if @verbose
		f=File.open(file_cidrs, 'r')
		f.each do |line|
			entry=line.chomp.split(',')
			next unless is_cidr?(entry[0])
			puts "Loading: #{entry[0]}" if @verbose
			key=entry[0].strip
			@known_cidr_blks = Hash.new unless @known_cidr_blks
			@known_cidr_blks[key] = Hash.new if not @known_cidr_blks.key?(key)
			@known_cidr_blks[key]['ref']=entry[1].nil? ? nil : entry[1].strip
			@known_cidr_blks[key]['netname']=entry[2].nil? ? nil : entry[2].strip
		end
		f.close
		if @known_cidr_blks
			@known_cidr_blks_asce_index=@known_cidr_blks.keys.sort
			@known_cidr_blks_desc_index=@known_cidr_blks_asce_index.reverse
		end
	end
def load_cidr_blks_from_file ( file_cidrs = @cidr_seeds ) puts "Load the known CIDR seed file: #{file_cidrs}" if @verbose f = File . open ( file_cidrs , 'r' ) f . each do | line | entry = line . chomp . split ( ',' ) next unless is_cidr? ( entry [ 0 ] ) puts "Loading: #{entry[0]}" if @verbose key = entry [ 0 ] . strip @known_cidr_blks = Hash . new unless @known_cidr_blks @known_cidr_blks [ key ] = Hash . new if not @known_cidr_blks . key? ( key ) @known_cidr_blks [ key ] [ 'ref' ] = entry [ 1 ] . nil? ? nil : entry [ 1 ] . strip @known_cidr_blks [ key ] [ 'netname' ] = entry [ 2 ] . nil? ? nil : entry [ 2 ] . strip end f . close if @known_cidr_blks @known_cidr_blks_asce_index = @known_cidr_blks . keys . sort @known_cidr_blks_desc_index = @known_cidr_blks_asce_index . reverse end end
'setter' to load the known CIDR blocks into an instance variable @known_cidr_blks
' setter ' to load the known CIDR blocks into an instance variable @known_cidr_blks
# Sort the blocks in order once for better performance. Update 10/29/2018 to support Netaddr 2.x syntax #@known_cidr_blks_desc_index=NetAddr.sort(@known_cidr_blks.keys, :Desc=>true) #@known_cidr_blks_asce_index=NetAddr.sort(@known_cidr_blks.keys, :Desc=>false) #rescue => ee #	puts "Exception on method #{__method__}: #{ee}" # if @verbose
file_cidrs
<not_specific>