proxy_finder 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d4cd3e417c3e87fd22a2e47459d149a7635c1dd3
4
+ data.tar.gz: f71f5f97c29e87bbc37f2235e8c36572172b9772
5
+ SHA512:
6
+ metadata.gz: 92c4c210419f5f9d252ec853afa06fe22288d6961acf43059407ba494e97e2cb81ae7e5a43f798071fc90fba0cccec48b32cd3938774684a0fca47a8cdc899c3
7
+ data.tar.gz: fd0544b5582e7da16656742ccc8e8dce65a089aaf2052c4c4c150792116f4ce86dee4d87d7e06bb5c7e716ef35a84f832f76b6a76801a2d92a16afc45fcb5adb
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org/'
2
+
3
+ gemspec
data/README.md ADDED
File without changes
data/bin/proxy_finder ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'proxy_finder'
4
+ require 'optparse'
5
+
6
+ files = Hash.new
7
+
8
+ option_parser = OptionParser.new do |opts|
9
+
10
+ opts.banner = "Usage: proxy_finder -i INFILE -o OUTFILE"
11
+
12
+ opts.on('-i', '--infile FILENAME', 'File containing hosts to test.') do |filename|
13
+ files[:infile] = filename
14
+ end
15
+
16
+ opts.on('-o', '--outfile FILENAME', 'File to output working hosts.') do |filename|
17
+ files[:outfile] = filename
18
+ end
19
+
20
+ opts.on("-h", "--help", "This usage menu.") do
21
+ puts option_parser
22
+ end
23
+
24
+ end
25
+
26
+ option_parser.parse!
27
+
28
+ unless files[:infile] && files[:outfile]
29
+ puts option_parser
30
+ end
31
+
32
+ # Allows halting via ctrl-c
33
+ trap("SIGINT") { throw :ctrl_c }
34
+
35
+ catch :ctrl_c do
36
+ pf = ProxyFinder.new
37
+ pf.start(files)
38
+ end
@@ -0,0 +1,48 @@
1
+ require 'net/ping'
2
+ require 'ruby-progressbar'
3
+
4
+ class ProxyFinder
5
+
6
+ def initialize
7
+ @progressbar
8
+ end
9
+
10
+ def start(files)
11
+
12
+ infile = File.open(files[:infile], 'r')
13
+ outfile = File.open(files[:outfile], 'a')
14
+
15
+ # Get number of lines in file to set the progress bar's width
16
+ # Rewind the file pointer because apparently `count` advances it to the end
17
+ lines = infile.count
18
+ infile.rewind
19
+
20
+ @progressbar = ProgressBar.create(title: 'Checking hosts...',
21
+ format: '%a |%b>>%i| %p%% %t',
22
+ length: 80,
23
+ total: lines)
24
+
25
+ infile.readlines.map {|line| line.rstrip}.each do |host|
26
+
27
+ # Displaying progress
28
+ @progressbar
29
+
30
+ # Extracting IP Address and Port from host
31
+ ip, port = host.split(':')
32
+ port = 80 if port.nil?
33
+
34
+ # Carriage return, blanking up to last host length, carriage return
35
+ if Net::Ping::HTTP.new(ip, port).ping?
36
+ outfile.puts host
37
+ end
38
+
39
+ @progressbar.increment
40
+
41
+ end
42
+
43
+ infile.close
44
+ outfile.close
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.required_ruby_version = '>= 2.1.0'
4
+
5
+ s.name = 'proxy_finder'
6
+ s.version = '0.0.1'
7
+ s.date = '2013-02-15'
8
+ s.summary = 'Find an active proxy server given a list of servers.'
9
+ s.description = 'Give proxy_finder a list of proxy servers and it will tell which ones are active.'
10
+ s.author = 'Frank S.'
11
+ s.email = 'franksort@gmail.com'
12
+ s.homepage = 'https://github.com/franksort/proxy_finder'
13
+ s.license = 'MIT'
14
+ s.executables << 'proxy_finder'
15
+
16
+ s.add_runtime_dependency('net-ping', '~> 1.7')
17
+ s.add_runtime_dependency('ruby-progressbar', '~> 1.4')
18
+
19
+ # s.add_development_dependency('net-ping', '~> 1.7')
20
+
21
+ s.files = ['bin/proxy_finder',
22
+ 'lib/proxy_finder.rb',
23
+ 'Gemfile',
24
+ 'proxy_finder.gemspec',
25
+ 'README.md']
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proxy_finder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Frank S.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: net-ping
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-progressbar
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ description: Give proxy_finder a list of proxy servers and it will tell which ones
42
+ are active.
43
+ email: franksort@gmail.com
44
+ executables:
45
+ - proxy_finder
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - Gemfile
50
+ - README.md
51
+ - bin/proxy_finder
52
+ - lib/proxy_finder.rb
53
+ - proxy_finder.gemspec
54
+ homepage: https://github.com/franksort/proxy_finder
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.1.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.2.1
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Find an active proxy server given a list of servers.
78
+ test_files: []