nx-spys-proxy 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 42e232fee2ff08f7169ac3a381c55b2bd2e930dccd91363eccc07301b9bca2a9
4
- data.tar.gz: b1355adad22a7c1f87a4bf817e863f0da48d0030e1198a134ab26811ffc4f11f
3
+ metadata.gz: d5147d462f30b65079e689dd7f60384cfc950387df72465b2dcd65face97df3d
4
+ data.tar.gz: da1d9692f8b0029a29db86aa47f05131e3a1b56b697a7228721804a0907105fc
5
5
  SHA512:
6
- metadata.gz: a108378439f970164eeba9645f0afe4a7199bba3bf45afe1002ca91c5e3d0269ddd63f99949bb628384bff3f29c4a4a3b6827e38a4f630386749bbefaf255e07
7
- data.tar.gz: 2bf4974c36aaf501adfc18fb39db995ba136e4690b6d83dbfbafdf51fe31930a5d3f73221632c0e5242d72adc55cb5c6e6d5215c41ddb5921bd93781518b9cd9
6
+ metadata.gz: 83e1e5b36de486a9216c5ccd27e218e7837384b60dcf60c5d728a22d5a5ffec36ba3d78907ad1ae5ed88518ff96fcdd8785a8a56d80f19785a492f89f8db1fa3
7
+ data.tar.gz: 38540e5d9563a83713647ada5a1188a64f0276213006f2e7b7752ee7057915a155304540700f0ada3c5de830f7edd53bc3a3e347889313c3b8b358af5812f802
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in templates.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # nx-spys-proxy
2
+ > Spys proxy.
3
+
4
+ ## installation
5
+ ```rb
6
+ # from gem
7
+ gem 'nx-spys-proxy'
8
+ # from git
9
+ gem 'nx-spys-proxy', git: 'git@github.com:afeiship/nx-spys-proxy.git'
10
+ ```
11
+
12
+ ## usage
13
+ ```rb
14
+ Nx::SpysProxy::hello
15
+
16
+ # hello world
17
+ ```
18
+
19
+ ## build/publish
20
+ ```shell
21
+ # build
22
+ gem build nx-spys-proxy.gemspec
23
+
24
+ # publish
25
+ gem push nx-spys-proxy-0.1.0.gem
26
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nx-spys-proxy"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,80 @@
1
+ require "net/http"
2
+ require "uri"
3
+ require "nokogiri"
4
+ require "open-uri"
5
+
6
+ module Nx
7
+ class SpysProxy
8
+ def self.fetch
9
+ data = []
10
+ ports = [3128, 8080, 80]
11
+ proxy_app = SpysProxy.new
12
+ ports.each do |port|
13
+ data += proxy_app.fetch(port)
14
+ end
15
+ data
16
+ end
17
+
18
+ def initialize(proxy = "http://127.0.0.1:9090")
19
+ @proxy = proxy
20
+ @ip_re = /\d+\.\d+\.\d+\.\d+/
21
+ @ports = {
22
+ 3128 => "1",
23
+ 8080 => "2",
24
+ 80 => "3",
25
+ }
26
+ end
27
+
28
+ def value
29
+ doc = Nokogiri::HTML(
30
+ open(
31
+ "http://spys.one/free-proxy-list/CN/",
32
+ read_timeout: 5,
33
+ proxy: @proxy,
34
+ )
35
+ )
36
+
37
+ doc.css('input[name="xx0"]').to_a[0].get_attribute("value")
38
+ end
39
+
40
+ def fetch(port)
41
+ uri = URI.parse("http://spys.one/free-proxy-list/CN/")
42
+ data = {
43
+ xx0: value,
44
+ xpp: 0,
45
+ xf1: 0,
46
+ xf2: 0,
47
+ xf4: @ports[port],
48
+ xf5: 1,
49
+ }
50
+
51
+ # xf4: 1 -> 3128
52
+ # xf4: 2 -> 8080
53
+ # xf4: 3 -> 80
54
+
55
+ # xf5: 1 -> http
56
+ # xf5: 2 -> socket
57
+
58
+ # Create the HTTP objects
59
+ http = Net::HTTP.new(uri.host, uri.port, "127.0.0.1", "9090")
60
+ request = Net::HTTP::Post.new(uri.request_uri)
61
+ request.content_type = "application/x-www-form-urlencoded"
62
+ request.body = URI.encode_www_form(data)
63
+
64
+ # Send the request
65
+ response = http.request(request)
66
+
67
+ doc = Nokogiri::HTML(
68
+ response.body
69
+ )
70
+
71
+ table = doc.css("table td > table")[0]
72
+ data = []
73
+ matches = table.text.scan(@ip_re).each do |ip|
74
+ data << { ip: ip, port: port.to_s }
75
+ end
76
+
77
+ data.uniq
78
+ end
79
+ end
80
+ end
data/lib/nx/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Nx
2
+ class SpysProxy
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "./nx/version"
2
+ require "./nx/spys-proxy"
Binary file
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nx/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nx-spys-proxy"
8
+ spec.version = Nx::SpysProxy::VERSION
9
+ spec.licenses = ["MIT"]
10
+ spec.authors = ["afeiship"]
11
+ spec.email = ["1290657123@qq.com"]
12
+
13
+ spec.summary = %q{Spys proxy.}
14
+ spec.description = %q{Spys proxy for next.}
15
+ spec.homepage = "https://github.com/afeiship/nx-spys-proxy"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.14"
34
+ spec.add_development_dependency "rake", "~> 12.3", ">= 12.3.3"
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nx-spys-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - afeiship
@@ -50,7 +50,18 @@ email:
50
50
  executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
- files: []
53
+ files:
54
+ - ".gitignore"
55
+ - Gemfile
56
+ - README.md
57
+ - Rakefile
58
+ - bin/console
59
+ - bin/setup
60
+ - lib/nx-spys-proxy.rb
61
+ - lib/nx/spys-proxy.rb
62
+ - lib/nx/version.rb
63
+ - nx-spys-proxy-0.1.0.gem
64
+ - nx-spys-proxy.gemspec
54
65
  homepage: https://github.com/afeiship/nx-spys-proxy
55
66
  licenses:
56
67
  - MIT