lib/hooray/seek.rb in hooray-0.1.8 vs lib/hooray/seek.rb in hooray-0.1.9
- old
+ new
@@ -9,11 +9,10 @@
TIMEOUT = 1
RANGE_REGEX = /\.{2,3}/
def initialize(network = nil, *params)
@scan = {}
- @bots = []
config_network network
config_filters params
end
def config_network(str)
@@ -54,11 +53,11 @@
#
# Creates a bot per port on IP
def scan_bot(ip)
(ports || [nil]).each do |port|
- @bots << Thread.new do
+ Thread.new do
if ping_class.new(ip.to_s, port, TIMEOUT).ping?
@scan[ip] << port
print '.'
end
end
@@ -71,10 +70,10 @@
def sweep
network.to_range.each do |ip|
@scan[ip] = []
scan_bot(ip)
end
- @bots.each(&:join)
+ Thread.list.reject { |t| t == Thread.current }.each(&:join)
@scan.reject! { |_k, v| v.empty? }
end
def to_s
"Seek #{network} #{ports}"