lib/wmap/host_tracker.rb
# Setter to load the known hosts from the local hosts file into a class instance
Setter to load the known hosts from the local hosts file into a class instance
Setter to load the known hosts from the local hosts file into a class instance
def load_known_hosts_from_file (f_hosts=@hosts_file)
		puts "Loading local hosts from file: #{f_hosts} ..." if @verbose
		known_hosts=Hash.new
		@alias = Hash.new
		File.write(f_hosts, "") unless File.exist?(f_hosts)
		f=File.open(f_hosts, 'r')
		f.each do |line|
			next unless line =~ /\d+\.\d+\.\d+\.\d+/
			entry=line.chomp.split(%r{\t+|\s+|\,})
			key=entry[0].downcase
			value=entry[1]
			puts "Loading key value pair: #{key} - #{value}" if @verbose
			known_hosts[key] = Hash.new unless known_hosts.key?(key)
			known_hosts[key]= value
			known_hosts[value] = Hash.new unless known_hosts.key?(value)
			known_hosts[value] = key
			if @alias.key?(value)
				@alias[value]+=1
			else
				@alias[value]=1
			end
		end
		f.close
		return known_hosts
	end
def load_known_hosts_from_file ( f_hosts = @hosts_file ) puts "Loading local hosts from file: #{f_hosts} ..." if @verbose known_hosts = Hash . new @alias = Hash . new File . write ( f_hosts , "" ) unless File . exist? ( f_hosts ) f = File . open ( f_hosts , 'r' ) f . each do | line | next unless line =~ / \d + \. \d + \. \d + \. \d + / entry = line . chomp . split ( %r{ \t +| \s +| \, } ) key = entry [ 0 ] . downcase value = entry [ 1 ] puts "Loading key value pair: #{key} - #{value}" if @verbose known_hosts [ key ] = Hash . new unless known_hosts . key? ( key ) known_hosts [ key ] = value known_hosts [ value ] = Hash . new unless known_hosts . key? ( value ) known_hosts [ value ] = key if @alias . key? ( value ) @alias [ value ] += 1 else @alias [ value ] = 1 end end f . close return known_hosts end
Setter to load the known hosts from the local hosts file into a class instance
Setter to load the known hosts from the local hosts file into a class instance
# For reverse host lookup # Count the number of alias for the recorded IP #rescue => ee #	puts "Exception on method #{__method__}: #{ee}" #	return known_hosts
f_hosts
<not_specific>