Sha256: 64c2cce3e4f5558ce0d5eda2eebba928ef13b227a78a882dc362d6706577e5b2
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require 'net/ping' require 'ruby-progressbar' class ProxyFinder def initialize @progressbar end 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
proxy_finder-0.0.1 | lib/proxy_finder.rb |