hidemyass2 1.0.1 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81daf30436f054fe6c5d00d0a65f3278e5225b7d
4
- data.tar.gz: a8bc68d272b7e71af5808c8fc13bf03764c1cfc0
3
+ metadata.gz: 3cc56ceea3c002eea107248fe58041e11b466189
4
+ data.tar.gz: 0ac795de36bd83039765d57dc6d9155d5a13d55e
5
5
  SHA512:
6
- metadata.gz: d17a7c7a96096f8dd132c15c819c34962ff5298d5ec178d64729edf15386b229cc069e85b15379190ba96dd6ea1b60c553cba3a1dc5e986d1b3c1580f094837b
7
- data.tar.gz: 47d567766e3f75ce23edc547570cfd08dfeb823a7520de4061bbf50f6db582a62d321e4b2b786c40285847357dbd152f9131a20ddd077ad85d2be74549277c01
6
+ metadata.gz: 8322738781cefcf98cc7fbe7628202995b11a6aa539bea9396473cc261705cb32b4aa47863d52797f14a5fd793324b64f9cb633eaebc5549c37c25245d902e64
7
+ data.tar.gz: 00a2454206d63cb9df488256bffea114653208f54539f9f475d1b9bbb2dbcf5c59fde108ae5d8eb2750d076689d1fff90af43cbbb8178505d157c7445b8aae15
data/README.md CHANGED
@@ -1,12 +1,18 @@
1
1
  # HIDE MY ASS! /2 [![Build Status](https://travis-ci.org/appPlant/hidemyass2.svg?branch=master)](https://travis-ci.org/appPlant/hidemyass2) [![Code Climate](https://codeclimate.com/github/appPlant/hidemyass2/badges/gpa.svg)](https://codeclimate.com/github/appPlant/hidemyass2) [![Test Coverage](https://codeclimate.com/github/appPlant/hidemyass2/badges/coverage.svg)](https://codeclimate.com/github/appPlant/hidemyass2/coverage) [![Dependency Status](https://gemnasium.com/badges/github.com/appPlant/hidemyass2.svg)](https://gemnasium.com/github.com/appPlant/hidemyass2)
2
2
 
3
- Hide My Ass! /2 fetches proxies at www.hidemyass.com to allow everyone to surf privately from anywhere.
3
+ Hide My Ass! /2 fetches proxies at https://incloak.com to allow everyone to surf privately from anywhere.
4
4
 
5
5
  - Proxy lists are checked in real time
6
6
 
7
- - Sortable by speed, with the fastest proxies listed first
7
+ - Around __1.000__ proxies at all
8
8
 
9
- - Sortable by country, anonymity, ...
9
+ - Sortable by speed, country, anonymity and many more
10
+
11
+ The graph shows the amount of change dynamics in the proxy list for the last 2 days.
12
+
13
+ <p align="left">
14
+ <img src="https://incloak.com/images/last_2days_mini.png"></img>
15
+ </p>
10
16
 
11
17
  ## Installation
12
18
 
@@ -26,42 +32,52 @@ Or install it yourself as:
26
32
 
27
33
  ## Usage
28
34
 
29
- To fetch all proxies simply run `HideMyAss.proxies`.
35
+ From terminal execute:
36
+
37
+ $ bundle exec hidemyass
38
+
39
+ https://188.166.233.171:8080
40
+ http://187.85.207.47:3128
41
+ http://201.22.213.7:8080
42
+ https://103.253.146.197:8080
43
+ https://139.59.226.223:8080
44
+ socks4://80.255.139.145:1080
45
+ socks5://5.135.151.28:60088
46
+ ...
47
+
48
+ For Ruby run:
30
49
 
31
50
  ```ruby
32
51
  require 'hidemyass'
33
52
 
34
- proxies = HideMyAss.proxies
35
- # => ProxyList
53
+ HideMyAss.proxies
54
+ #<HideMyAss::ProxyList:0x00000000000000 @uri="..." @proxies=[...]>
36
55
  ```
37
56
 
38
- To reuse that list instead of fetching a new one use `HideMyAss.proxies!`.
57
+ __Note:__ To reuse that list instead of fetching a new one use `HideMyAss.proxies!`.
39
58
 
40
- To fetch proxies matching some criteria simply add filter options. Use `HideMyAss.form_data` to see and modify their defaults.
59
+ #### Filter proxies
41
60
 
42
61
  ```ruby
43
62
  require 'hidemyass'
44
63
 
45
- # c[] - Countries
46
- # p - Port. Defaults to all ports.
47
- # pr[] - Protocol. 0..2 = HTTP, HTTPS, socks4/5
48
- # a[] - Anonymity level. 0..4 = None, Low, Medium, High, High +KA
49
- # sp[] - Speed. 0..2 = Slow, Medium, Fast.
50
- # ct[] - Connection time. 0..2 = Slow, Medium, Fast
51
- # s - Sort. 0..3 = Response time, Connection time, Country A-Z.
52
- # o - Order. 0, 1 = DESC, ASC.
53
- # pp - Per Page. 0..3 = 10, 25, 50, 100.
54
- # sortBy - Sort by. Defaults to date.
64
+ # start - Offset. Defaults to 0.
65
+ # end - Max. number of proxies to fetch. Defaults to 2000.
66
+ # countries - Country. Defaults to all countries.
67
+ # ports - Port. Defaults to any port.
68
+ # type - Protocol. h = HTTP, s = HTTPS, 4 = SOCKS4, 5 = SOCKS5
69
+ # anon - Anonymity level. 1..4 = None, Low, Medium, High
70
+ # maxtime - Speed in milliseconds.
55
71
 
56
- proxies = HideMyAss.proxies 'c[]' => 'France', sortBy: 'response_time'
72
+ proxies = HideMyAss.proxies countries: 'FR', type: 'hs'
57
73
 
58
74
  proxies.first.country
59
75
  # => 'france'
60
76
  ```
61
77
 
62
- Visit http://proxylist.hidemyass.com for more informations how to filter.
78
+ Visit https://incloak.com/proxy-list/ for more informations how to filter.
63
79
 
64
- To get the url of each proxy call `proxy.url`.
80
+ #### Get the url of each proxy
65
81
 
66
82
  ```ruby
67
83
  require 'hidemyass'
@@ -72,10 +88,6 @@ urls = HideMyAss.proxies.map(&:url)
72
88
 
73
89
  Refer to the [Proxy](https://github.com/appPlant/hidemyass2/blob/master/lib/hidemyass/proxy.rb) class for more advanced usage and a complete list of properties like `speed`, `ip`, `ssl?`, `anonym?` or `secure?`.
74
90
 
75
- Print out all proxy urls on command line:
76
-
77
- $ bundle exec hidemyass
78
-
79
91
  ## Development
80
92
 
81
93
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -33,62 +33,34 @@ module HideMyAss
33
33
  @row = row
34
34
  end
35
35
 
36
- # Time in seconds when the last ping was made.
37
- #
38
- # @return [ Int ]
39
- def last_updated
40
- @last_updated ||= begin
41
- @row.at_xpath('td[1]').text.strip.split(' ').map do |it|
42
- case it
43
- when /sec/ then it.scan(/\d+/)[0].to_i
44
- when /min/ then it.scan(/\d+/)[0].to_i * 60
45
- when /h/ then it.scan(/\d+/)[0].to_i * 3_600
46
- when /d/ then it.scan(/\d+/)[0].to_i * 86_400
47
- end
48
- end.reduce(&:+)
49
- end
50
- end
51
-
52
- alias last_test last_updated
53
-
54
36
  # The IP of the proxy server.
55
37
  #
56
38
  # @return [ String ]
57
39
  def ip
58
- @ip ||= @row.at_xpath('td[2]/span').children
59
- .select { |el| ip_block? el }
60
- .map! { |el| el.text.strip }
61
- .join('')
40
+ @ip ||= @row.at_xpath('td[1]/text()').text.strip
62
41
  end
63
42
 
64
43
  # The port for the proxy.
65
44
  #
66
45
  # @return [ Int ]
67
46
  def port
68
- @port ||= @row.at_xpath('td[3]').text.strip.to_i
47
+ @port ||= @row.at_xpath('td[2]/text()').text.strip.to_i
69
48
  end
70
49
 
71
50
  # The country where the proxy is hosted in downcase letters.
72
51
  #
73
52
  # @return [ String ]
74
53
  def country
75
- @country ||= @row.at_xpath('td[4]').text.strip.downcase
54
+ @country ||= @row.at_xpath('td[3]/div/text()')
55
+ .text.strip.downcase!.scan(/[[:word:]]+$/).last
76
56
  end
77
57
 
78
58
  # The average response time in milliseconds.
79
59
  #
80
60
  # @return [ Int ]
81
61
  def speed
82
- @speed ||= @row.at_xpath('td[5]/div')[:value].to_i
83
- end
84
-
85
- alias response_time speed
86
-
87
- # The average connection time in milliseconds.
88
- #
89
- # @return [ Int ]
90
- def connection_time
91
- @connection_time ||= @row.at_xpath('td[6]/div')[:value].to_i
62
+ @speed ||= @row.at_xpath('td[4]/div/div/p/text()')
63
+ .text.scan(/^\d+/)[0].to_i
92
64
  end
93
65
 
94
66
  # The network protocol in in downcase letters.
@@ -96,7 +68,7 @@ module HideMyAss
96
68
  #
97
69
  # @return [ String ]
98
70
  def type
99
- @type ||= @row.at_xpath('td[7]').text.strip.downcase[0..4]
71
+ @type ||= @row.at_xpath('td[5]/text()').text.strip.split.last.downcase!
100
72
  end
101
73
 
102
74
  alias protocol type
@@ -106,21 +78,28 @@ module HideMyAss
106
78
  #
107
79
  # @return [ String ]
108
80
  def anonymity
109
- @anonymity ||= @row.at_xpath('td[8]').text.strip.downcase
81
+ @anonymity ||= @row.at_xpath('td[6]').text.strip.downcase!
110
82
  end
111
83
 
112
- # The complete URL of that proxy server.
84
+ # Time in minutes when its been last checked.
85
+ #
86
+ # @return [ Int ]
87
+ def last_check
88
+ @last_check ||= @row.at_xpath('td[7]/text()').text.scan(/^\d+/)[0].to_i
89
+ end
90
+
91
+ # The relative URL without the leading protocol.
113
92
  #
114
93
  # @return [ String ]
115
- def url
116
- "#{protocol}://#{ip}:#{port}"
94
+ def rel_url
95
+ "#{ip}:#{port}"
117
96
  end
118
97
 
119
- # If the IP is valid.
98
+ # The complete URL of that proxy server.
120
99
  #
121
- # @return [ Boolean ]
122
- def valid?
123
- ip.split('.').reject(&:empty?).count == 4
100
+ # @return [ String ]
101
+ def url
102
+ "#{protocol}://#{rel_url}"
124
103
  end
125
104
 
126
105
  # If the proxy's network protocol is HTTP.
@@ -165,7 +144,6 @@ module HideMyAss
165
144
  anonym? && ssl?
166
145
  end
167
146
 
168
- # :nocov:
169
147
  # Custom inspect method.
170
148
  #
171
149
  # @example
@@ -173,27 +151,10 @@ module HideMyAss
173
151
  # => '<HideMyAss::Proxy http://123.57.52.171:80>'
174
152
  #
175
153
  # @return [ String ]
154
+ # :nocov:
176
155
  def inspect
177
156
  "<#{self.class.name} #{url}>"
178
157
  end
179
158
  # :nocov:
180
-
181
- private
182
-
183
- # To find out if the element is a part of the IP.
184
- #
185
- # @param [ Nokogiri::XML ] el
186
- #
187
- # @return [ Boolean ]
188
- def ip_block?(el)
189
- return el[:style].include? 'in' if el[:style]
190
-
191
- @clss ||= @row.at_xpath('td[2]/span/style').text.split
192
- .map! { |it| it[1..4] if it !~ /none/ }.compact
193
-
194
- cls = el[:class].to_s
195
-
196
- el.name == 'text' || @clss.include?(cls) || cls =~ /^\d+$/
197
- end
198
159
  end
199
160
  end
@@ -17,7 +17,7 @@ module HideMyAss
17
17
  include Enumerable
18
18
  extend Forwardable
19
19
 
20
- ENDPOINT = 'http://proxylist.hidemyass.com'.freeze
20
+ ENDPOINT = 'https://incloak.com/proxy-list/?start=0&end=2000'.freeze
21
21
 
22
22
  private_constant :ENDPOINT
23
23
 
@@ -27,30 +27,37 @@ module HideMyAss
27
27
  #
28
28
  # @return [ HideMyAss::ProxyList ]
29
29
  def initialize(form_data = HideMyAss.form_data)
30
- self.form_data = form_data.dup
31
- @proxies = fetch.keep_if(&:valid?)
30
+ self.form_data = form_data.reject { |_, v| v.nil? }
31
+ @proxies = fetch
32
32
  end
33
33
 
34
+ def_delegator :@proxies, :each
35
+
34
36
  # Form data to support custom searches
37
+ #
38
+ # @return [ Hash ]
35
39
  attr_accessor :form_data
36
40
 
37
- def_delegator :@proxies, :each
41
+ # Build URI for endpoint including all search form params.
42
+ #
43
+ # @return [ URI ]
44
+ def uri
45
+ uri = URI(ENDPOINT)
46
+ uri.query = URI.encode_www_form(form_data)
47
+ uri
48
+ end
38
49
 
39
50
  private
40
51
 
41
52
  # Fetch list of all proxies.
42
53
  #
43
54
  # @return [ Array<HideMyAss::Proxy> ]
44
- def fetch(url = ENDPOINT)
45
- res = Net::HTTP.post_form(URI(url), form_data)
46
- page = Nokogiri::HTML(res.body, nil, 'UTF-8')
47
- sel_row = '//table[@id="listable"]/tbody/tr'
48
- sel_lnk = 'section > section.section-component > section.hma-pagination li.arrow.next:not(.unavailable) > a' # rubocop:disable Metrics/LineLength
49
-
50
- proxies = page.xpath(sel_row).map { |row| Proxy.new(row) }
51
- link = page.at_css(sel_lnk)
55
+ def fetch
56
+ body = Net::HTTP.get(uri)
57
+ page = Nokogiri::HTML(body, nil, 'UTF-8')
58
+ sel = '//*[@id="content-section"]/section[1]/div/table/tbody/tr'
52
59
 
53
- link ? proxies.concat(fetch("#{ENDPOINT}#{link[:href]}")) : proxies
60
+ page.xpath(sel).map { |row| Proxy.new(row) }
54
61
  rescue Timeout::Error
55
62
  []
56
63
  end
@@ -1,3 +1,3 @@
1
1
  module HideMyAss
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
data/lib/hidemyass.rb CHANGED
@@ -69,28 +69,21 @@ module HideMyAss
69
69
 
70
70
  # Get form data for custom search.
71
71
  #
72
- # c[] - Countries
73
- # p - Port. Defaults to all ports.
74
- # pr[] - Protocol. 0..2 = HTTP, HTTPS, socks4/5
75
- # a[] - Anonymity level. 0..4 = None, Low, Medium, High, High +KA
76
- # sp[] - Speed. 0..2 = Slow, Medium, Fast.
77
- # ct[] - Connection time. 0..2 = Slow, Medium, Fast
78
- # s - Sort. 0..3 = Response time, Connection time, Country A-Z.
79
- # o - Order. 0, 1 = DESC, ASC.
80
- # pp - Per Page. 0..3 = 10, 25, 50, 100.
81
- # sortBy - Sort by. Defaults to date.
72
+ # start - Offset. Defaults to 0.
73
+ # end - Max. number of proxies to fetch. Defaults to 2000.
74
+ # countries - Country. Defaults to all countries.
75
+ # ports - Port. Defaults to any port.
76
+ # type - Protocol. h = HTTP, s = HTTPS, 4 = SOCKS4, 5 = SOCKS5
77
+ # anon - Anonymity level. 1..4 = None, Low, Medium, High
78
+ # maxtime - Speed in milliseconds.
82
79
  #
83
80
  # @return [ Hash ]
84
81
  def self.form_data
85
- @form_data ||= { 'c[]' => nil,
86
- 'p' => nil,
87
- 'pr[]' => [0, 1],
88
- 'a[]' => [3, 4],
89
- 'sp[]' => [1, 2, 3],
90
- 'ct[]' => [1, 2, 3],
91
- 's' => 1,
92
- 'o' => 0,
93
- 'pp' => 3,
94
- 'sortBy' => 'response_time' }
82
+ @form_data ||= { start: 0,
83
+ end: 2000,
84
+ anon: nil,
85
+ type: nil,
86
+ ports: nil,
87
+ maxtime: nil }
95
88
  end
96
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hidemyass2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastián Katzer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-08 00:00:00.000000000 Z
11
+ date: 2016-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler