class NetCrawl
Constants
- CFG
- Config
- DNS
- Log
Attributes
hosts[R]
Public Class Methods
new()
click to toggle source
# File lib/netcrawl.rb, line 39 def initialize @methods = [] @hosts = {} @poll = PollMap.new CFG.use.each do |method| begin method = File.basename method.to_s file = 'netcrawl/method/' + method.downcase require_relative file @methods.push NetCrawl.const_get(method) rescue NameError, LoadError raise MethodNotFound, "unable to find method '#{method}'" end end end
Public Instance Methods
crawl(host)
click to toggle source
@param [String] host host to start crawl from @return [NetCrawl::Output]
# File lib/netcrawl.rb, line 9 def crawl host recurse host Output.new @hosts, @poll end
get(host)
click to toggle source
@param [String] host host to get list of peers from @return [Array] list of peers seen connected to host
# File lib/netcrawl.rb, line 16 def get host peers = [] @methods.each do |method| peers += method.send(:peers, host) end peers.uniq { |peer| peer.ip } end
recurse(host)
click to toggle source
Given string of IP address, recurses through peers seen and populates @hosts hash @param [String] host host to start recurse from @return [void]
# File lib/netcrawl.rb, line 27 def recurse host peers = get host @hosts[host] = peers peers.each do |peer| next if @hosts.has_key? peer.ip next unless @poll.include? peer.ip crawl peer.ip end end