lib/wmap/site_tracker.rb
# Setter to load the known hosts into an instance variable
Setter to load the known hosts into an instance variable
Setter to load the known hosts into an instance variable
def load_site_stores_from_file (file=@sites_file)
		puts "Loading the site store data repository from file: #{file} " if @verbose
		@known_sites=Hash.new
		File.write(file, "") unless File.exist?(file)
		f=File.open(file, 'r')
		f.each do |line|
			line=line.chomp.strip
			next if line.nil?
			next if line.empty?
			next if line =~ /^\s*#/
			entry=line.split(%r{\t+|\,})
			site=entry[0].downcase
			ip=entry[1]
			port=entry[2]
			status=entry[3]
			server=entry[4]
			res=entry[5].to_i
			fp=entry[6]
			loc=entry[7]
			timestamp=entry[8]
			puts "Loading entry: #{site} - #{ip} - #{status}" if @verbose
			@known_sites[site]= Hash.new unless @known_sites.key?(site)
			@known_sites[site]['ip']=ip
			@known_sites[site]['port']=port
			@known_sites[site]['status']=status
			@known_sites[site]['server']=server
			@known_sites[site]['code']=res
			@known_sites[site]['md5']=fp
			@known_sites[site]['redirection']=loc
			@known_sites[site]['timestamp']=timestamp
		end
		f.close
		puts "Successfully loading file: #{file}" if @verbose
		return @known_sites
	rescue => ee
		puts "Exception on method #{__method__} for file #{file}: #{ee}"
	end
def load_site_stores_from_file ( file = @sites_file ) puts "Loading the site store data repository from file: #{file} " if @verbose @known_sites = Hash . new File . write ( file , "" ) unless File . exist? ( file ) f = File . open ( file , 'r' ) f . each do | line | line = line . chomp . strip next if line . nil? next if line . empty? next if line =~ / ^ \s *# / entry = line . split ( %r{ \t +| \, } ) site = entry [ 0 ] . downcase ip = entry [ 1 ] port = entry [ 2 ] status = entry [ 3 ] server = entry [ 4 ] res = entry [ 5 ] . to_i fp = entry [ 6 ] loc = entry [ 7 ] timestamp = entry [ 8 ] puts "Loading entry: #{site} - #{ip} - #{status}" if @verbose @known_sites [ site ] = Hash . new unless @known_sites . key? ( site ) @known_sites [ site ] [ 'ip' ] = ip @known_sites [ site ] [ 'port' ] = port @known_sites [ site ] [ 'status' ] = status @known_sites [ site ] [ 'server' ] = server @known_sites [ site ] [ 'code' ] = res @known_sites [ site ] [ 'md5' ] = fp @known_sites [ site ] [ 'redirection' ] = loc @known_sites [ site ] [ 'timestamp' ] = timestamp end f . close puts "Successfully loading file: #{file}" if @verbose return @known_sites rescue => ee puts "Exception on method #{__method__} for file #{file}: #{ee}" end
Setter to load the known hosts into an instance variable
Setter to load the known hosts into an instance variable
file
<not_specific>