rest-tor 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 +4 -4
- data/README.md +3 -1
- data/lib/rest_tor/utils.rb +3 -3
- data/lib/rest_tor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f201b4acba40f747a5e9563f43db9b8e69560d45
|
4
|
+
data.tar.gz: cb18946fdf67e37d96b417bc64f1ed824af89658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7074b36afe2ec36598e2288e349c458dcb3d3c5afebaf0b06d443d8b04f48ae83808f9ea8077a81d48aa0990f48d9f88cabab041d93e888405c0ede3bab45ae4
|
7
|
+
data.tar.gz: 23fe7019b7492c38c983e3eca78d4a5e3b756bc56606e29526855b29249948bb65a2b4b14364bbd1fb8ad8d355282a9cb00c5e06c7b4734634fafb11dfd8f719
|
data/README.md
CHANGED
@@ -26,6 +26,7 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
+
```ruby
|
29
30
|
Tor.request(url: 'http://ip.plusor.cn/')
|
30
31
|
=> #<Nokogiri::HTML::Document:0x3fcd64ec6eb0 name="document" children=[#<Nokogiri::XML::DTD:0x3fcd64ec6af0 name="html">, #<Nokogiri::XML::Element:0x3fcd64ec67f8 name="html" children=[#<Nokogiri::XML::Element:0x3fcd64ec6618 name="body" children=[#<Nokogiri::XML::Element:0x3fcd64ec6438 name="p" children=[#<Nokogiri::XML::Text:0x3fcd64ec6258 "185.100.85.101\n">]>]>]>]>
|
31
32
|
|
@@ -33,7 +34,7 @@ Or install it yourself as:
|
|
33
34
|
"64.113.32.29\n"
|
34
35
|
|
35
36
|
Tor.request(url: 'http://ip.plusor.cn/', mobile: true) # RestClient.get "http://ip.plusor.cn/", "", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"0", "Content-Type"=>"application/x-www-form-urlencoded", "User-Agent"=>"ANDROID_KFZ_COM_2.0.9_M6 Note_7.1.2"
|
36
|
-
Tor.request(url: 'http://ip.plusor.cn/')
|
37
|
+
Tor.request(url: 'http://ip.plusor.cn/') # RestClient.get "http://ip.plusor.cn/", "", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"0", "Content-Type"=>"application/x-www-form-urlencoded", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
|
37
38
|
|
38
39
|
Tor.request(method: :post, url: '...', format: :json, mobile: true)
|
39
40
|
=> {'hello' => 'world'}
|
@@ -88,6 +89,7 @@ Or install it yourself as:
|
|
88
89
|
I, [2017-12-15T20:46:42.588824 #60422] INFO -- : Testing tor 9010
|
89
90
|
I, [2017-12-15T20:47:02.179464 #60422] INFO -- : IP: 173.254.216.66
|
90
91
|
|
92
|
+
```
|
91
93
|
|
92
94
|
## TODO
|
93
95
|
|
data/lib/rest_tor/utils.rb
CHANGED
@@ -3,14 +3,14 @@ module Tor
|
|
3
3
|
def to_json(body)
|
4
4
|
JSON.parse(body)
|
5
5
|
rescue Exception => e
|
6
|
-
|
6
|
+
logger.info "#{e.class}:#{e.message}"
|
7
7
|
{}
|
8
8
|
end
|
9
9
|
|
10
10
|
def number_to_human_size(num, options={})
|
11
11
|
ActiveSupport::NumberHelper::NumberToHumanSizeConverter.convert num, options
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def encode_html(body)
|
15
15
|
if /<meta .*?content=".*?charset=(\w+)"/ =~ body.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
|
16
16
|
encode = $1
|
@@ -18,7 +18,7 @@ module Tor
|
|
18
18
|
begin
|
19
19
|
body = body.dup.force_encoding(encode).encode("utf-8", invalid: :replace, under: :replace)
|
20
20
|
rescue Exception => e
|
21
|
-
|
21
|
+
logger.info "#{e.class}:#{e.message}(Tor.request)"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/rest_tor/version.rb
CHANGED