From 93a22fd37b99d429c00fe59cac6bab97338fe83c Mon Sep 17 00:00:00 2001 From: danijoo Date: Sat, 13 Feb 2016 03:25:07 +0100 Subject: [PATCH] cleaned code --- adbwifiscan.rb | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/adbwifiscan.rb b/adbwifiscan.rb index ca07a82..ef63993 100644 --- a/adbwifiscan.rb +++ b/adbwifiscan.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require 'ADB' require 'ipaddr' -require 'thread' ip_range = IPAddr.new(ARGV[0]).to_range.to_a abort "Please pass an ip range as first arg" unless ip_range @@ -29,22 +28,18 @@ puts "Scan started..." queue = Queue.new ip_range.each { |ip| queue << ip} -threads = Array.new -# (queue.size / 10).times do - # threads << Thread.new do - begin - ip = queue.pop(true) - print "#{ip}\r" - adb.connect(ip.to_s, port, timeout) - puts "Device found! #{ip}" - rescue ThreadError - nil - rescue - retry - end - # end -# end +begin + ip = queue.pop(true) + print "#{ip}\r" + adb.connect(ip.to_s, port, timeout) + puts "Device found! #{ip}" +rescue ThreadError + nil +rescue + retry +end + puts "\nScan complete" puts "Connected devices: #{adb.devices}"