cleaned code
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
require 'ADB'
|
require 'ADB'
|
||||||
require 'ipaddr'
|
require 'ipaddr'
|
||||||
require 'thread'
|
|
||||||
|
|
||||||
ip_range = IPAddr.new(ARGV[0]).to_range.to_a
|
ip_range = IPAddr.new(ARGV[0]).to_range.to_a
|
||||||
abort "Please pass an ip range as first arg" unless ip_range
|
abort "Please pass an ip range as first arg" unless ip_range
|
||||||
@@ -29,22 +28,18 @@ puts "Scan started..."
|
|||||||
|
|
||||||
queue = Queue.new
|
queue = Queue.new
|
||||||
ip_range.each { |ip| queue << ip}
|
ip_range.each { |ip| queue << ip}
|
||||||
threads = Array.new
|
|
||||||
|
|
||||||
# (queue.size / 10).times do
|
begin
|
||||||
# threads << Thread.new do
|
|
||||||
begin
|
|
||||||
ip = queue.pop(true)
|
ip = queue.pop(true)
|
||||||
print "#{ip}\r"
|
print "#{ip}\r"
|
||||||
adb.connect(ip.to_s, port, timeout)
|
adb.connect(ip.to_s, port, timeout)
|
||||||
puts "Device found! #{ip}"
|
puts "Device found! #{ip}"
|
||||||
rescue ThreadError
|
rescue ThreadError
|
||||||
nil
|
nil
|
||||||
rescue
|
rescue
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
# end
|
|
||||||
# end
|
|
||||||
puts "\nScan complete"
|
puts "\nScan complete"
|
||||||
puts "Connected devices: #{adb.devices}"
|
puts "Connected devices: #{adb.devices}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user