Class: Wmap::SiteTracker::DeactivatedSite

Inherits:
Wmap::SiteTracker show all
Includes:
Singleton, Utils
Defined in:
lib/wmap/site_tracker/deactivated_site.rb

Constant Summary

Constants included from Utils::UrlMagic

Utils::UrlMagic::Max_http_timeout, Utils::UrlMagic::User_agent

Constants included from Utils::DomainRoot

Utils::DomainRoot::File_ccsld, Utils::DomainRoot::File_cctld, Utils::DomainRoot::File_gtld, Utils::DomainRoot::File_tld

Instance Attribute Summary collapse

Attributes inherited from Wmap::SiteTracker

#max_parallel

Instance Method Summary collapse

Methods included from Utils

#cidr_2_ips, #file_2_hash, #file_2_list, #get_nameserver, #get_nameservers, #host_2_ip, #host_2_ips, #is_cidr?, #is_fqdn?, #is_ip?, #list_2_file, #reverse_dns_lookup, #sort_ips, #valid_dns_record?, #zone_transferable?

Methods included from Utils::Logger

#wlog

Methods included from Utils::UrlMagic

#create_absolute_url_from_base, #create_absolute_url_from_context, #host_2_url, #is_site?, #is_ssl?, #is_url?, #landing_location, #make_absolute, #normalize_url, #open_page, #redirect_location, #response_code, #response_headers, #url_2_host, #url_2_path, #url_2_port, #url_2_site, #urls_on_same_domain?

Methods included from Utils::DomainRoot

#get_domain_root, #get_domain_root_by_ccsld, #get_domain_root_by_cctld, #get_domain_root_by_tlds, #get_sub_domain, #is_domain_root?, #print_ccsld, #print_cctld, #print_gtld

Methods inherited from Wmap::SiteTracker

#bulk_add, #bulk_delete, #bulk_refresh, #count, #file_add, #file_delete, #file_refresh, #get_ext_sites, #get_int_sites, #get_ip_sites, #get_prim_uniq_sites, #get_redirection_url, #get_redirection_urls, #get_ssl_sites, #get_uniq_sites, #is_trusted?, #load_site_stores_from_file, #print_all_sites, #print_ext_sites, #print_int_sites, #print_ip_sites, #print_site, #print_ssl_sites, #print_uniq_sites, #refresh, #refresh_all, #refresh_ip_sites, #refresh_uniq_sites, #resolve_ip_sites, #save_sites_to_file!, #save_uniq_sites, #save_uniq_sites_xml, #search, #site_check, #site_ip_known?, #site_known?

Constructor Details

#initialize(params = {}) ⇒ DeactivatedSite

Set default instance variables



23
24
25
26
27
28
29
30
31
32
# File 'lib/wmap/site_tracker/deactivated_site.rb', line 23

def initialize (params = {})
	# Initialize the instance variables
	@data_dir=params.fetch(:data_dir, File.dirname(__FILE__)+'/../../../data/')
	Dir.mkdir(@data_dir) unless Dir.exist?(@data_dir)
	@sites_file=params.fetch(:sites_file, @data_dir + 'deactivated_sites')
	@verbose=params.fetch(:verbose, false)
	# Hash table to hold the site store
	File.new(@sites_file, "w") unless File.exist?(@sites_file)
	@known_sites=load_site_stores_from_file(@sites_file)
end

Instance Attribute Details

#data_dirObject

Returns the value of attribute data_dir.



20
21
22
# File 'lib/wmap/site_tracker/deactivated_site.rb', line 20

def data_dir
  @data_dir
end

#known_sitesObject

Returns the value of attribute known_sites.



20
21
22
# File 'lib/wmap/site_tracker/deactivated_site.rb', line 20

def known_sites
  @known_sites
end

#sites_fileObject

Returns the value of attribute sites_file.



20
21
22
# File 'lib/wmap/site_tracker/deactivated_site.rb', line 20

def sites_file
  @sites_file
end

#verboseObject

Returns the value of attribute verbose.



20
21
22
# File 'lib/wmap/site_tracker/deactivated_site.rb', line 20

def verbose
  @verbose
end

Instance Method Details

#add(site, entry) ⇒ Object

Deactivate obsolete entrance from the live site store. Note this method is used by the parent class only



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/wmap/site_tracker/deactivated_site.rb', line 35

def add (site,entry)
	begin
		puts "Deactivate site: #{site}" if @verbose
		@known_sites[site]=Hash.new unless @known_sites.key?(site)
		@known_sites[site]['ip']=entry['ip']
		@known_sites[site]['port']=entry['port']
		@known_sites[site]['status']=entry['status']
		@known_sites[site]['server']=entry['server']
		@known_sites[site]['md5']=entry['md5']
		@known_sites[site]['redirection']=entry['redirection']
		@known_sites[site]['timestamp']=entry['timestamp']
		@known_sites[site]['code']=entry['code']
		puts "Deactivate site entry loaded: #{entry}"
	rescue Exception => ee
		puts "Exception on method #{__method__}: #{ee}" if @verbose
		return nil
	end

end

#delete(site) ⇒ Object

Refresh re-activated entrance in the store. Note this method is used by the parent class only



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/wmap/site_tracker/deactivated_site.rb', line 56

def delete (site)
	begin
		puts "Reactivate site: #{site}" if @verbose
		site=site.strip.downcase unless site.nil?
		@known_sites.delete(site)
		puts "Site removed from the de-activated list."
	rescue Exception => ee
		puts "Exception on method #{__method__}: #{ee}" if @verbose
		return nil
	end

end

#update_from_site_store!Object Also known as: update!

Procedures to discover deactivated sites from the live site store to here in one shot (TBD).



70
71
72
73
74
75
76
77
78
# File 'lib/wmap/site_tracker/deactivated_site.rb', line 70

def update_from_site_store!
	puts "Invoke internal procedures to update the site store."
	begin
	# To be further developed
	rescue Exception => ee
		puts "Exception on method #{__method__}: #{ee}" if @verbose
		return nil
	end
end