Class: Probe::DomainProbe
- Inherits:
-
Object
- Object
- Probe::DomainProbe
- Defined in:
- lib/domain-probe.rb
Class Attribute Summary collapse
-
.policies ⇒ Object
Returns the value of attribute policies.
Class Method Summary collapse
-
.collect_ns_records(domain) ⇒ Object
collect the ns records.
-
.collect_records(domain) ⇒ Object
collect the records under domain domain.
- .register_policy(policy) ⇒ Object
- .unregister_policy(policy) ⇒ Object
Instance Method Summary collapse
- #collect_ns_records(domain) ⇒ Object
-
#collect_records(domain) ⇒ Object
collect the records under domain domain IF zone detection fails, return nil?.
Class Attribute Details
.policies ⇒ Object
Returns the value of attribute policies.
17 18 19 |
# File 'lib/domain-probe.rb', line 17 def policies @policies end |
Class Method Details
.collect_ns_records(domain) ⇒ Object
collect the ns records
41 42 43 |
# File 'lib/domain-probe.rb', line 41 def self.collect_ns_records domain self.new().collect_ns_records domain end |
.collect_records(domain) ⇒ Object
collect the records under domain domain
34 35 36 |
# File 'lib/domain-probe.rb', line 34 def self.collect_records domain self.new().collect_records domain end |
.register_policy(policy) ⇒ Object
22 23 24 25 |
# File 'lib/domain-probe.rb', line 22 def self.register_policy policy raise ArgumentError, "policy need respond_to? possible_host_under_domain" unless policy.kind_of? Policy self.policies << policy end |
.unregister_policy(policy) ⇒ Object
27 28 29 |
# File 'lib/domain-probe.rb', line 27 def self.unregister_policy policy self.policies.delete policy end |
Instance Method Details
#collect_ns_records(domain) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/domain-probe.rb', line 124 def collect_ns_records domain raise ArgumentError, "Domain name is expected" unless domain domain = zone = Util.detect_zone(domain.downcase) return [] if !zone || is_tld(zone) executor = ThreadExecutor.new nameservers = Util.detect_nameservers zone.split(".").last #NS records executor.submit_task(domain,Net::DNS::NS,zone,nameservers) executor.execute_util_finished executor.ns_records end |
#collect_records(domain) ⇒ Object
collect the records under domain domain IF zone detection fails, return nil?
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/domain-probe.rb', line 49 def collect_records domain raise ArgumentError, "Domain name is expected" unless domain domain = zone = Util.detect_zone(domain.downcase) return {} if !zone || is_tld(zone) nameservers = detect_nameservers zone possible_domains = Set.new DomainProbe.policies.each{ |policy| possible_domains |= policy.possible_host_under_domain(zone) } executor = ThreadExecutor.new #check to see if a wildcard record there? if yes, stop the probing executor.submit_task(wildcard_domain_name(zone),Net::DNS::A,zone,nameservers) executor.submit_task(wildcard_domain_name(zone),Net::DNS::AAAA,zone,nameservers) executor.execute_util_finished #start again executor.start_threads #A/AAAA/CNAME records possible_domains.each{ |possible_host| executor.submit_task(possible_domain_name(possible_host,zone),Net::DNS::A,zone,nameservers) executor.submit_task(possible_domain_name(possible_host,zone),Net::DNS::AAAA,zone,nameservers) } unless !executor.a_records.empty? || !executor.aaaa_records.empty? || !executor.cname_records.empty? #A/CNAME records executor.submit_task(domain,Net::DNS::A,zone,nameservers) #AAAA executor.submit_task(domain,Net::DNS::AAAA,zone,nameservers) #MX records executor.submit_task(domain,Net::DNS::MX,zone,nameservers) #MR records executor.submit_task(domain,Net::DNS::MR,zone,nameservers) #TXT records executor.submit_task(domain,Net::DNS::TXT,zone,nameservers) #HINFO records executor.submit_task(domain,Net::DNS::HINFO,zone,nameservers) #SRV records executor.submit_task(domain,Net::DNS::SRV,zone,nameservers) #SPF records executor.submit_task(domain,Net::DNS::SPF,zone,nameservers) #SOA records executor.submit_task(domain,Net::DNS::SOA,zone,nameservers) #NS records executor.submit_task(domain,Net::DNS::NS,zone,nameservers) executor.execute_util_finished results = { "a" => executor.a_records, "aaaa" => executor.aaaa_records, "cname" => executor.cname_records, "mx" => executor.mx_records, "mr" => executor.mr_records, "txt" => executor.txt_records, "hinfo" => executor.hinfo_records, "srv" => executor.srv_records, "ns" => executor.ns_records.select{|record| record[:name] != "@"}, "spf" => executor.spf_records, "soa" => executor.soa_records, "zone" => Util.remove_trailing_dot_if_any(zone) } end |