lib/wmap/host_tracker.rb
# Setter to add host entry to the cache once at a time
Setter to add host entry to the cache once at a time
Setter to add host entry to the cache once at a time
def add(host)
		puts "Add entry to the local host repository: #{host}"
		host=host.strip.downcase unless host.nil?
		root=get_domain_root(host)
		unless @known_hosts.key?(host)
			ip=host_2_ip(host)
			record=Hash.new
			if is_ip?(ip)
				if is_trusted?(host)
					record[host]=ip
					record[ip]=host
					puts "Host data repository entry loaded: #{host} <=> #{ip}"
					sub=get_sub_domain(host)
					if sub!=nil
						tracker=Wmap::DomainTracker::SubDomain.instance
						tracker.data_dir=@data_dir
						tracker.sub_domains_file = tracker.data_dir + "sub_domains"
						tracker.known_internet_sub_domains=tracker.load_domains_from_file(tracker.sub_domains_file)
						unless tracker.domain_known?(sub)
							tracker.add(sub)
							tracker.save!
						end
						tracker=nil
					end
					@known_hosts.merge!(record)
					return record
				else
					domain_tracker=nil
					puts "Error - host #{host} has an untrusted internet root domain: #{root}\nPlease update the trusted domain seeds file first if necessary."
				end
			else
				puts "Problem resolve host #{host} - unknown IP: #{ip}"
			end
		else
			puts "Host is already exist. Skip: #{host}"
		end
	end
def add ( host ) puts "Add entry to the local host repository: #{host}" host = host . strip . downcase unless host . nil? root = get_domain_root ( host ) unless @known_hosts . key? ( host ) ip = host_2_ip ( host ) record = Hash . new if is_ip? ( ip ) if is_trusted? ( host ) record [ host ] = ip record [ ip ] = host puts "Host data repository entry loaded: #{host} <=> #{ip}" sub = get_sub_domain ( host ) if sub != nil tracker = Wmap :: DomainTracker :: SubDomain . instance tracker . data_dir = @data_dir tracker . sub_domains_file = tracker . data_dir + "sub_domains" tracker . known_internet_sub_domains = tracker . load_domains_from_file ( tracker . sub_domains_file ) unless tracker . domain_known? ( sub ) tracker . add ( sub ) tracker . save! end tracker = nil end @known_hosts . merge! ( record ) return record else domain_tracker = nil puts "Error - host #{host} has an untrusted internet root domain: #{root}\nPlease update the trusted domain seeds file first if necessary." end else puts "Problem resolve host #{host} - unknown IP: #{ip}" end else puts "Host is already exist. Skip: #{host}" end end
Setter to add host entry to the cache once at a time
Setter to add host entry to the cache once at a time
# filter host to known domains only # Replace instance with the class variable to avoid potential race condition under parallel engine # add additional logic to update the sub-domain table as well, 02/10/2014 #rescue => ee #	puts "Exception on method #{__method__}: #{ee}" if @verbose
host
<not_specific>