proxy_service 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/proxy_service.rb +21 -7
- data/lib/proxy_service/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a67a8a9b6a6b147f03393b4ebe5509965468efc2
|
4
|
+
data.tar.gz: 1cc38b2a5767af0eb731941abf76dcb36368db8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdc70d07f3ed024aa0df07bae67eb7ab3ce8a00e476ca3fb4c9af9f605b8cac25a4254b00ba8347fa44d09e26a251c059fecf0f5c7746a7d3f840fca2018137a
|
7
|
+
data.tar.gz: 56aeff45fb3aa4babef7992ea397777a67e9cd5f1dea83a67d60ccc6ad898bc845d57eb89f65ace754479447a81817e4932cf92b8ac5ddd5796fec8a01b8729b
|
data/lib/proxy_service.rb
CHANGED
@@ -36,13 +36,9 @@ class ProxyService
|
|
36
36
|
yield agent
|
37
37
|
proxy.reset_failures
|
38
38
|
rescue Mechanize::ResponseCodeError => e
|
39
|
-
if failure_codes.include?(e.response_code)
|
40
|
-
|
41
|
-
|
42
|
-
else
|
43
|
-
proxy.increment_failures
|
44
|
-
end
|
45
|
-
end
|
39
|
+
block_or_increment_proxy if failure_codes.include?(e.response_code)
|
40
|
+
rescue ProxyBlockedError, ReCaptchaError
|
41
|
+
block_or_increment_proxy
|
46
42
|
ensure
|
47
43
|
proxy.release
|
48
44
|
end
|
@@ -51,6 +47,14 @@ class ProxyService
|
|
51
47
|
# Private
|
52
48
|
#
|
53
49
|
|
50
|
+
def block_or_increment_proxy
|
51
|
+
if proxy.failures >= failure_limit
|
52
|
+
proxy.blocked!
|
53
|
+
else
|
54
|
+
proxy.increment_failures
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
54
58
|
def proxies_enabled?
|
55
59
|
@proxies_enabled
|
56
60
|
end
|
@@ -77,6 +81,16 @@ class ProxyService
|
|
77
81
|
NullWorker.new
|
78
82
|
end
|
79
83
|
end
|
84
|
+
|
85
|
+
#
|
86
|
+
# Custom errors
|
87
|
+
#
|
88
|
+
|
89
|
+
class ProxyBlockedError < StandardError
|
90
|
+
end
|
91
|
+
|
92
|
+
class ReCaptchaError < StandardError
|
93
|
+
end
|
80
94
|
end
|
81
95
|
|
82
96
|
require 'proxy_service/mechanize_agent'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxy_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|