proxi_clean 0.2.0

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: 8585ff7158184fc594f0dbaf100da5a9eaa1074a
4
+ data.tar.gz: 36a1df89090d8bf793a94bc097aa87efe5ddd1e5
5
+ SHA512:
6
+ metadata.gz: 02eb2696509d65571b191549cb0c17c7b1627c3bbe2fdff645ac7246210d9e5632b400fd9c6d7482324857f42c359ea24a831da58049726e25aca16a1fc89aa4
7
+ data.tar.gz: 1b527695b43c8d4947fbf280cd6bc40a0b4f2fc258771cfbb925216e30717b8a8d674a4ce143cdfdbfb1af95515585459500079485c579691a48b294ca48c074
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ script: bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in proxi_clean.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Mario Zigliotto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ ![Proxi Clean Career Destroying Logo](http://i.imgur.com/eH4PWSe.png)
2
+
3
+ [![Build Status](https://travis-ci.org/mariozig/proxi_clean.png?branch=master)](https://travis-ci.org/mariozig/proxi_clean)
4
+
5
+
6
+ # ProxiClean
7
+
8
+ ## What is proxi_clean?
9
+
10
+ A simple utility for checking if an http proxy works or not. If you deal with huge lists of proxies and need to clean out the dead or non-functional ones, this might help you.
11
+
12
+ ## How does it work?
13
+ Using the power of oxygen `proxi_clean` will make a call to the [realip.info](http://www.realip.info/api/p/realip.php) API using `RestClient` and determine it's unproxied public IP. When checking if a proxy is valid or not `proxi_clean` reconfigures `RestClient` to use the proxy you provide and confirms that realip returns an IP address that does NOT match your unproxied public IP.
14
+
15
+ If anything goes wrong we blindly assume the proxy is no good.
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'proxi_clean'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ `$ bundle`
28
+
29
+ Or install it yourself as:
30
+
31
+ `$ gem install proxi_clean`
32
+
33
+ ## Usage
34
+
35
+ Easy! The API has 1 useful public method: `works?`. Just create a `client` and start checking proxies.
36
+
37
+ ```ruby
38
+ 2.2.1 :005 > client = ProxiClean::Client.new
39
+ => #<ProxiClean::Client:0x007fa149e78b18 @public_ip="47.202.47.103">
40
+ 2.2.1 :006 > client.works? 'https://124.88.67.13:843'
41
+ => true
42
+ 2.2.1 :007 > client.works? 'https://NOT-GONNA-WORK.com:47'
43
+ => false
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( https://github.com/mariozig/proxi_clean/fork )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "proxi_clean"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,40 @@
1
+ require 'rest_client'
2
+
3
+ module ProxiClean
4
+ class Client
5
+ attr_reader :public_ip
6
+
7
+ def initialize
8
+ public_ip
9
+ end
10
+
11
+ def works?(proxy_uri)
12
+ begin
13
+ proxied_ip = proxied_ip(proxy_uri)
14
+ rescue StandardError => e
15
+ # If anything goes wrong, assuming the proxy is no good
16
+ return false
17
+ end
18
+
19
+ public_ip != proxied_ip
20
+ end
21
+
22
+ def public_ip
23
+ RestClient.proxy = nil
24
+ # Try to not hit realip more than we really need
25
+ @public_ip ||= result_from_real_ip_api
26
+ end
27
+
28
+ private
29
+
30
+ def proxied_ip(proxy_uri)
31
+ RestClient.proxy = proxy_uri
32
+ result_from_real_ip_api
33
+ end
34
+
35
+ def result_from_real_ip_api
36
+ real_up_url = 'http://www.realip.info/api/p/realip.php'
37
+ JSON.parse(RestClient.get(real_up_url))['IP']
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module ProxiClean
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'proxi_clean/version'
2
+ require 'proxi_clean/client'
3
+
4
+ module ProxiClean
5
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'proxi_clean/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "proxi_clean"
8
+ spec.version = ProxiClean::VERSION
9
+ spec.authors = ["Mario Zigliotto"]
10
+ spec.email = ["mariozig@gmail.com"]
11
+
12
+ spec.summary = %q{Proxi Clean will check your proxy and tell you if it's working or not.}
13
+ spec.description = %q{Proxi Clean will check your proxy and tell you if it's working or not.}
14
+ spec.homepage = "http://github.com/mariozig/proxi_clean"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.8'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3'
27
+ spec.add_development_dependency 'webmock', '~> 1.20', '>= 1.20.4'
28
+ spec.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
29
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proxi_clean
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Mario Zigliotto
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.8.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.8.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.8'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.8'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: vcr
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.9'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.9.3
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '2.9'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 2.9.3
81
+ - !ruby/object:Gem::Dependency
82
+ name: webmock
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.20'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.20.4
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.20'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.20.4
101
+ - !ruby/object:Gem::Dependency
102
+ name: rspec
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '3.2'
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.2.0
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.2'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 3.2.0
121
+ description: Proxi Clean will check your proxy and tell you if it's working or not.
122
+ email:
123
+ - mariozig@gmail.com
124
+ executables: []
125
+ extensions: []
126
+ extra_rdoc_files: []
127
+ files:
128
+ - ".gitignore"
129
+ - ".rspec"
130
+ - ".travis.yml"
131
+ - Gemfile
132
+ - LICENSE.txt
133
+ - README.md
134
+ - Rakefile
135
+ - bin/console
136
+ - bin/setup
137
+ - lib/proxi_clean.rb
138
+ - lib/proxi_clean/client.rb
139
+ - lib/proxi_clean/version.rb
140
+ - proxi_clean.gemspec
141
+ homepage: http://github.com/mariozig/proxi_clean
142
+ licenses:
143
+ - MIT
144
+ metadata: {}
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.4.6
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: Proxi Clean will check your proxy and tell you if it's working or not.
165
+ test_files: []