Class | HostMap::Discovery::HostDiscovery::Host |
In: |
lib/discovery/host.rb
|
Parent: | Object |
alias | [RW] | List of hostnames for this IP. |
domains | [RW] | List of domains for this host. |
ip | [R] | Host IP address. |
mx | [RW] | List of host mail exchanges servers. |
ns | [RW] | List of nameservers that handle names for this host. |
# File lib/discovery/host.rb, line 219 def initialize(ip) @ip = ip @mx = Set.new @ns = Set.new @alias = Set.new @domains = Set.new end
Return host status in formatted text.
# File lib/discovery/host.rb, line 248 def to_txt(out = "") out << "Results for #{@ip}\n" out << "Served by name server (probably)\n" if @ns.size > 0 @ns.each {|a| out << "\t#{a}\n" } else out << "No results found." end out << "Served by mail exchange (probably)\n" if @mx.size > 0 @mx.each {|a| out << "\t#{a}\n" } else out << "No results found." end #out << "Part of domain (probably)\n" #@domains.each {|a| out << "\t#{a}\n" } out << "Hostnames:\n" if @alias.size > 0 @alias.each {|a| out << "\t#{a}\n" } else out << "No results found." end out end
Return host status as XML.
# File lib/discovery/host.rb, line 230 def to_xml doc = REXML::Document.new root = doc.add_element('host', { 'ip' => @ip, 'time' => Time.now}) {'mail server' => @ms, 'name server' => @ns, 'domain' => @domains, 'hostname' => @alias}.each do |key, value| if value.nil? next end value.each do |val| node = root.add_element(key) node.text = val end end doc end