proxy_fetcher 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ad122ebb9d6241313981ef764c41a1b940dfdc12
4
- data.tar.gz: 2cf2d359bfd74122fbfdf9d97d94c1e70b008cd5
2
+ SHA256:
3
+ metadata.gz: d5fee8c7b429b32d608388ddf15885d2354721d6de693396ad228248925cf2d6
4
+ data.tar.gz: '0250291040c511a723cdae4a22a78d4f765a0ca7b10325f331a8d119f8d25157'
5
5
  SHA512:
6
- metadata.gz: 4ebe17a6ebfb52a14267856053ad750676d4b28e85e138aa172d778b85368ec85ccd04af55cdceb53e1aaad3db5cdab09d42ee87767d56b1fc5578c1c6ba114b
7
- data.tar.gz: 6133dfc0b9810831ae7e79c2795ad3214a4b1c78df71e7a2a910429dd21d6b67a7a2f22c29b284fc30d68fff4ea9907fc39edefbb630027eb9a1e2cd4eb2ae24
6
+ metadata.gz: b7d12b75f0e80075d31832f8add9d1269ae48ff32714a0c0b481a85eb275094ccec62020911d55f74a2920211fc445f11ee3c31f43fdc7cc1f5ae2d175278eec
7
+ data.tar.gz: 138c464c0531fc12773b995d3101f5e952e2a4868e7e13d18274b27f7b0ea310a515d76e2066f36b25c2586c2046b9497f15a74e943cfbc8fdc8f0204796f93e
data/CHANGELOG.md CHANGED
@@ -4,7 +4,18 @@ Reverse Chronological Order:
4
4
 
5
5
  ## `master`
6
6
 
7
- * Add your changelog here
7
+ * Add your description here
8
+
9
+ ## `0.9.0` (2019-01-22)
10
+
11
+ * Fix a problem with stuck of proxies list loading.
12
+
13
+ * Add a possibility to configure different timeouts for different cases:
14
+ - `client_timeout` - timeout for `ProxyFetcher::Client`.
15
+ - `provider_proxies_load_timeout` - timeout for loading of proxies list by provider.
16
+ - `proxy_validation_timeout` - timeout for proxy validation with `ProxyFetcher::ProxyValidator`.
17
+
18
+ (old option `timeout` sets and returns value of `client_timeout`)
8
19
 
9
20
  ## `0.8.0` (2018-11-12)
10
21
 
data/lib/proxy_fetcher.rb CHANGED
@@ -54,7 +54,8 @@ module ProxyFetcher
54
54
  # ProxyFetcher.config
55
55
  #
56
56
  # #=> #<ProxyFetcher::Configuration:0x0000000241eec8 @user_agent="Mozilla/5.0, ...", @pool_size=10,
57
- # @timeout=3, @http_client=ProxyFetcher::HTTPClient, @proxy_validator=ProxyFetcher::ProxyValidator,
57
+ # @client_timeout=3, @proxy_validation_timeout=3, @provider_proxies_load_timeout=30,
58
+ # @http_client=ProxyFetcher::HTTPClient, @proxy_validator=ProxyFetcher::ProxyValidator,
58
59
  # @providers=[:free_proxy_list, ...], @adapter=ProxyFetcher::Document::NokogiriAdapter>
59
60
  #
60
61
  def config
@@ -56,7 +56,7 @@ module ProxyFetcher
56
56
  @method = args.fetch(:method).to_s.downcase
57
57
  @headers = (args[:headers] || {}).dup
58
58
  @payload = args[:payload]
59
- @timeout = args.fetch(:timeout, ProxyFetcher.config.timeout)
59
+ @timeout = args.fetch(:timeout, ProxyFetcher.config.client_timeout)
60
60
  @ssl_options = args.fetch(:ssl_options, default_ssl_options)
61
61
 
62
62
  @proxy = args.fetch(:proxy)
@@ -5,9 +5,21 @@ module ProxyFetcher
5
5
  # with HTTP requests, adapters, custom classes.
6
6
  #
7
7
  class Configuration
8
- # @!attribute timeout
9
- # @return [Integer] HTTP request connection / open timeout
10
- attr_accessor :timeout
8
+ # @!attribute client_timeout
9
+ # @return [Integer] HTTP request timeout (connect / open) for [ProxyFetcher::Client]
10
+ attr_accessor :client_timeout
11
+
12
+ # @!attribute provider_proxies_load_timeout
13
+ # @return [Integer] HTTP request timeout (connect / open) for loading of proxies list by provider
14
+ attr_accessor :provider_proxies_load_timeout
15
+
16
+ # @!attribute proxy_validation_timeout
17
+ # @return [Integer] HTTP request timeout (connect / open) for proxy validation with [ProxyFetcher::ProxyValidator]
18
+ attr_accessor :proxy_validation_timeout
19
+
20
+ # to save compatibility
21
+ alias timeout client_timeout
22
+ alias timeout= client_timeout=
11
23
 
12
24
  # @!attribute pool_size
13
25
  # @return [Integer] proxy validator pool size (max number of threads)
@@ -98,7 +110,10 @@ module ProxyFetcher
98
110
  @logger = Logger.new(STDOUT)
99
111
  @user_agent = DEFAULT_USER_AGENT
100
112
  @pool_size = 10
101
- @timeout = 3
113
+ @client_timeout = 3
114
+ @provider_proxies_load_timeout = 30
115
+ @proxy_validation_timeout = 3
116
+
102
117
  @http_client = HTTPClient
103
118
  @proxy_validator = ProxyValidator
104
119
 
@@ -17,6 +17,10 @@ module ProxyFetcher
17
17
  # @return [OpenSSL::SSL::SSLContext] SSL context
18
18
  attr_reader :ssl_ctx
19
19
 
20
+ # @!attribute [r] timeout
21
+ # @return [Integer] Request timeout
22
+ attr_reader :timeout
23
+
20
24
  # Fetches resource content by sending HTTP request to it.
21
25
  # Synthetic sugar to simplify URIes fetching.
22
26
  #
@@ -36,6 +40,7 @@ module ProxyFetcher
36
40
  def initialize(url)
37
41
  @url = url.to_s
38
42
  @http = HTTP.headers(default_headers)
43
+ @timeout = ProxyFetcher.config.provider_proxies_load_timeout
39
44
 
40
45
  @ssl_ctx = OpenSSL::SSL::SSLContext.new
41
46
  @ssl_ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -47,7 +52,9 @@ module ProxyFetcher
47
52
  # response body
48
53
  #
49
54
  def fetch
50
- @http.get(url, ssl_context: ssl_ctx).body.to_s
55
+ @http.timeout(connect: timeout, read: timeout)
56
+ .get(url, ssl_context: ssl_ctx)
57
+ .body.to_s
51
58
  rescue StandardError
52
59
  ProxyFetcher.logger.warn("Failed to load proxy list for #{url}")
53
60
  ''
@@ -28,7 +28,7 @@ module ProxyFetcher
28
28
  # @return [ProxyValidator]
29
29
  #
30
30
  def initialize(proxy_addr, proxy_port)
31
- timeout = ProxyFetcher.config.timeout
31
+ timeout = ProxyFetcher.config.proxy_validation_timeout
32
32
 
33
33
  @http = HTTP.follow.via(proxy_addr, proxy_port.to_i).timeout(connect: timeout, read: timeout)
34
34
  end
@@ -13,7 +13,7 @@ module ProxyFetcher
13
13
  # Major version number
14
14
  MAJOR = 0
15
15
  # Minor version number
16
- MINOR = 8
16
+ MINOR = 9
17
17
  # Smallest version number
18
18
  TINY = 0
19
19
 
@@ -20,5 +20,6 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.add_runtime_dependency 'http', '~> 3.0'
22
22
 
23
+ gem.add_development_dependency 'rake', '>= 12.0'
23
24
  gem.add_development_dependency 'rspec', '~> 3.5'
24
25
  end
@@ -10,7 +10,7 @@ xdescribe ProxyFetcher::Client do
10
10
  before :all do
11
11
  ProxyFetcher.configure do |config|
12
12
  config.provider = :xroxy
13
- config.timeout = 5
13
+ config.client_timeout = 5
14
14
  end
15
15
 
16
16
  @server = EvilProxy::MITMProxyServer.new Port: 3128, Quiet: true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_fetcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Bulai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-12 00:00:00.000000000 Z
11
+ date: 2019-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -120,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
134
  - !ruby/object:Gem::Version
121
135
  version: '0'
122
136
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.6.11
137
+ rubygems_version: 3.0.2
125
138
  signing_key:
126
139
  specification_version: 4
127
140
  summary: Ruby gem for dealing with proxy lists from different providers