class ProxyFinder
Public Class Methods
new()
click to toggle source
# File lib/proxy_finder.rb, line 6 def initialize @progressbar end
Public Instance Methods
start(files)
click to toggle source
# File lib/proxy_finder.rb, line 10 def start(files) infile = File.open(files[:infile], 'r') outfile = File.open(files[:outfile], 'a') # Get number of lines in file to set the progress bar's width # Rewind the file pointer because apparently `count` advances it to the end lines = infile.count infile.rewind @progressbar = ProgressBar.create(title: 'Checking hosts...', format: '%a |%b>>%i| %p%% %t', length: 80, total: lines) infile.readlines.map {|line| line.rstrip}.each do |host| # Displaying progress @progressbar # Extracting IP Address and Port from host ip, port = host.split(':') port = 80 if port.nil? # Carriage return, blanking up to last host length, carriage return if Net::Ping::HTTP.new(ip, port).ping? outfile.puts host end @progressbar.increment end infile.close outfile.close end