proxied 0.1.2 → 0.1.3

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
2
  SHA256:
3
- metadata.gz: 4b63589961f4cbc4d46a03c5c97d88171f5a86af86e6a58f47042336e38fd58d
4
- data.tar.gz: e3ae83908238864b37d9d6d78ba1a914157898cf9430fc946d39e8480d7ff5ab
3
+ metadata.gz: c3225511d5ca688c62c4c41138f7dfa135b766a1ca22de15f638c76a4bc805e6
4
+ data.tar.gz: ddaa33c4df250b5b868eb98262b0c87dc3c0ad099fd9343989f77c18e16a8d74
5
5
  SHA512:
6
- metadata.gz: feb8cbe47e0563025c8c497242a5ab3aa982be099a6b457d3bee2dae64f710ec2d67e368eb25de5f0fdaee0249c924c073a9c2a9d1b6d3c3dc9bcc2654eb7448
7
- data.tar.gz: a0799134b33788cc919808258a3add09fd881fb7a082de3a62ca91182c831ac4a23fa90827673cd436802537c5f9b021219e32dab2fc196ad1c74a64070dc3e5
6
+ metadata.gz: 107c196e83c9a87d27674c89cb6f6384b5c69a689e3c2c0d818f0241bddec129180bbc39e0e16599abc15e1eb10e76e308e5aa038c13478fd2e74b5ba57b435d
7
+ data.tar.gz: 9d5d1cfed81dad98ec888d571e2e1cfcac30cc8e0d6898e60c4edad01538eada8936621363c016b6e0c75998d714771cd8e3bcd6a864794f332c1659a025063f
data/README.md CHANGED
@@ -32,10 +32,27 @@ Generate the migration and model:
32
32
 
33
33
  $ rails generate proxied MODEL
34
34
 
35
+ ## Features
36
+
37
+ Features:
38
+
39
+ * ActiveRecord model and migration or Mongoid model for managing your proxy data.
40
+
41
+ * Common model methods for selecting random proxies (based on protocol, etc.) for both ActiveRecord and Mongoid.
42
+
43
+ * A proxy checker to check the status for HTTP(S) and Socks proxies (with configurable test setups).
44
+
45
+ * An importer that will bulk import proxies for you.
46
+
47
+ * Sidekiq jobs to asynchronously check proxies.
35
48
 
36
49
  ## Usage
37
50
 
38
- - TODO -
51
+ 1. Set up the gem according to the installation instructions.
52
+ 2. Import proxies.
53
+ 3. Schedule the rake task (proxied:check_proxies) using cron or schedule the Sidekiq job (Proxied::Jobs::CheckProxiesJob) using a scheduler for Sidekiq.
54
+ 4. Use the model methods to query for valid proxies (the maximum failed attempts etc. are configurable using the global Proxied.configure-method).
55
+ 5. Use the proxies/proxy from the resulting query to perform HTTP(S) or SOCKS requests using the proxy. Some helper methods, e.g. #proxy_options_for_faraday are included to help with integration with some common gems.
39
56
 
40
57
  ## Development
41
58
 
@@ -54,7 +71,7 @@ In order to test specific specs: ADAPTER=mongoid bundle exec appraisal mongoid7
54
71
 
55
72
  ## Contributing
56
73
 
57
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/proxied. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
74
+ Bug reports and pull requests are welcome on GitHub at https://github.com/SebastianJ/proxied. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
58
75
 
59
76
  ## License
60
77
 
@@ -62,4 +79,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
62
79
 
63
80
  ## Code of Conduct
64
81
 
65
- Everyone interacting in the Proxied project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/proxied/blob/master/CODE_OF_CONDUCT.md).
82
+ Everyone interacting in the Proxied project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/SebastianJ/proxied/blob/master/CODE_OF_CONDUCT.md).
@@ -1,15 +1,17 @@
1
1
  module Proxied
2
2
  class Checker
3
+ attr_accessor :mode
3
4
  attr_accessor :minimum_successful_attempts, :maximum_failed_attempts
4
5
  attr_accessor :limit
5
6
 
6
- def initialize(minimum_successful_attempts: ::Proxied.configuration.minimum_successful_attempts, maximum_failed_attempts: ::Proxied.configuration.maximum_failed_attempts, limit: nil)
7
+ def initialize(mode: :synchronous, minimum_successful_attempts: ::Proxied.configuration.minimum_successful_attempts, maximum_failed_attempts: ::Proxied.configuration.maximum_failed_attempts, limit: nil)
8
+ self.mode = mode
7
9
  self.minimum_successful_attempts = minimum_successful_attempts
8
10
  self.maximum_failed_attempts = maximum_failed_attempts
9
11
  self.limit = limit
10
12
  end
11
13
 
12
- def check_proxies(protocol: :all, proxy_type: :all, mode: :synchronous, update: true)
14
+ def check_proxies(protocol: :all, proxy_type: :all, update: true)
13
15
  proxies = ::Proxied.configuration.proxy_class.constantize.should_be_checked(
14
16
  protocol: protocol,
15
17
  proxy_type: proxy_type,
@@ -22,10 +24,10 @@ module Proxied
22
24
  ::Proxied::Logger.log "Found #{proxies.size} #{proxy_type} proxies to check."
23
25
 
24
26
  proxies.each do |proxy|
25
- case mode
27
+ case self.mode.to_sym
26
28
  when :synchronous
27
29
  check_proxy(proxy, update: update)
28
- when :sidekiq
30
+ when :asynchronous
29
31
  ::Proxied::Jobs::CheckProxyJob.perform_async(proxy.id.to_s)
30
32
  end
31
33
  end
@@ -66,7 +68,7 @@ module Proxied
66
68
  end
67
69
 
68
70
  def check_http_proxy(proxy, test_url: ::Proxied.configuration.http_test[:url], timeout: ::Proxied.configuration.http_test[:timeout], update: true)
69
- ::Proxied::Logger.log "#{Time.now}: Fetching robots.txt for Google.com with proxy #{proxy.proxy_address}. Using authentication? #{proxy.proxy_credentials}"
71
+ ::Proxied::Logger.log "#{Time.now}: Fetching robots.txt for Google.com with proxy #{proxy.proxy_address}."
70
72
 
71
73
  response = request(test_url, proxy, options: {timeout: timeout})
72
74
  valid_proxy = (response && !(response =~ /Allow: \/search\/about/i).nil?)
@@ -16,7 +16,7 @@ module Proxied
16
16
  self.faraday = {
17
17
  adapter: :net_http,
18
18
  user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Safari/605.1.15",
19
- verbose: true
19
+ verbose: false
20
20
  }
21
21
 
22
22
  self.http_test = {
@@ -4,8 +4,8 @@ module Proxied
4
4
  include ::Sidekiq::Worker
5
5
  sidekiq_options queue: ::Proxied.configuration.job_queue
6
6
 
7
- def perform(protocol = :all, proxy_type = :all, mode = :synchronous)
8
- ::Proxied::Checker.new.check_proxies(protocol: protocol.to_sym, proxy_type: proxy_type.to_sym, mode: mode.to_sym, update: true)
7
+ def perform(protocol = :all, proxy_type = :all, mode = :asynchronous)
8
+ ::Proxied::Checker.new(mode: mode.to_sym).check_proxies(protocol: protocol.to_sym, proxy_type: proxy_type.to_sym, update: true)
9
9
  end
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module Proxied
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -2,12 +2,11 @@ namespace :proxied do
2
2
  task :check_proxies, [:protocol, :proxy_type, :mode, :maximum_failed_attempts] => :environment do |task, args|
3
3
  args.with_defaults(protocol: :http, proxy_type: :public, mode: :synchronous, maximum_failed_attempts: 10)
4
4
 
5
- checker = ::Proxied::Checker.new
5
+ checker = ::Proxied::Checker.new(mode: args.mode.to_sym, maximum_failed_attempts: args.maximum_failed_attempts.to_i)
6
6
  checker.check_proxies(
7
- protocol: args.protocol.to_sym,
8
- proxy_type: args.proxy_type.to_sym,
9
- mode: args.mode.to_sym,
10
- maximum_failed_attempts: args.maximum_failed_attempts.to_i
7
+ protocol: args.protocol.to_sym,
8
+ proxy_type: args.proxy_type.to_sym,
9
+
11
10
  )
12
11
  end
13
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxied
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian