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 +4 -4
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +26 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/nx/spys-proxy.rb +80 -0
- data/lib/nx/version.rb +5 -0
- data/lib/nx-spys-proxy.rb +2 -0
- data/nx-spys-proxy-0.1.0.gem +0 -0
- data/nx-spys-proxy.gemspec +35 -0
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5147d462f30b65079e689dd7f60384cfc950387df72465b2dcd65face97df3d
|
4
|
+
data.tar.gz: da1d9692f8b0029a29db86aa47f05131e3a1b56b697a7228721804a0907105fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83e1e5b36de486a9216c5ccd27e218e7837384b60dcf60c5d728a22d5a5ffec36ba3d78907ad1ae5ed88518ff96fcdd8785a8a56d80f19785a492f89f8db1fa3
|
7
|
+
data.tar.gz: 38540e5d9563a83713647ada5a1188a64f0276213006f2e7b7752ee7057915a155304540700f0ada3c5de830f7edd53bc3a3e347889313c3b8b358af5812f802
|
data/.gitignore
ADDED
data/Gemfile
ADDED
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
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,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
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.
|
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
|