Permalink
Browse files

make using a www. prefix optional, increment the version number so ol…

…d caches don't get used on subsequent runs
  • Loading branch information...
1 parent 3fcb05e commit 2758e7dd774f1016ae775755ce8efac5f46231ce @jpf committed May 20, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/domain-profiler/information.rb
@@ -11,19 +11,23 @@ def status(message)
def fetch(host)
data = {}
#TODO: Automatically generate a 'version' - checksum this file or class?
- version = 'v4'
+ version = 'v5'
+ use_www_prefix_for_a_record_lookups = true
+
dns_server = '208.67.222.222' # OpenDNS
# dns_server = '4.2.2.2' # Level 3
filename = "cache/#{host}.#{version}.cache"
if File.exists?(filename)
data = open(filename) { |f| Marshal.load(f) }
else
data[:version] = version
+ if use_www_prefix_for_a_record_lookups
+ host_prefix = 'www.'
+ end
status "Fetching data for #{host}: DNS "
- extended_host = "www." + host
dnsopt = '+noadditional +noauthority'
- data[:dns] = `server=#{dns_server}; host=#{host}; dig @$server ns $host #{dnsopt}; dig @$server a $host #{dnsopt}; dig @$server a #{extended_host} #{dnsopt}; dig @$server mx $host #{dnsopt}; dig @$server txt $host #{dnsopt}`
+ data[:dns] = `server=#{dns_server}; host=#{host}; dig @$server ns $host #{dnsopt}; dig @$server a $host #{dnsopt}; dig @$server a #{host_prefix}#{host} #{dnsopt}; dig @$server mx $host #{dnsopt}; dig @$server txt $host #{dnsopt}`
status 'Whois '
data[:whois] = `sleep 2; whois 'domain #{host}'`

0 comments on commit 2758e7d

Please sign in to comment.