ruby_bittorrent 1.0.1 → 1.0.2
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/VERSION +1 -1
- data/lib/bit_torrent.rb +13 -1
- data/ruby_bittorrent.gemspec +1 -1
- data/spec/bit_torrent_spec.rb +16 -0
- 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: c201b204aef4f4aefdc3f52c3417681fbb29af01
|
4
|
+
data.tar.gz: ffe5c2365fe2af62db3ef5c9b54b15dc19240537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74fac05bcc170d67a16921ae65f4291fac54d22920dc9c845f15f14888179b765b1c1d6d105b75762cb7bfacac6325601e4be245d9f51bafc6b2b44cb3def5f6
|
7
|
+
data.tar.gz: d7cb2324a86608e7c8f42dc94bebd360d851ac2d2be170877252cab14804ce3f2ad192ab93bd212b9103eb0f785fb83b922cdbfc524d96c3a46d90087b7b3d99
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/bit_torrent.rb
CHANGED
@@ -10,6 +10,7 @@ class BitTorrent
|
|
10
10
|
:connect_timeout => 60,
|
11
11
|
:timeout => 60,
|
12
12
|
:stop_timeout => 0,
|
13
|
+
:use_tor_proxy => false,
|
13
14
|
:destination_directory => "."
|
14
15
|
}
|
15
16
|
|
@@ -56,8 +57,19 @@ class BitTorrent
|
|
56
57
|
"--bt-tracker-connect-timeout=#{connect_timeout}",
|
57
58
|
"--bt-tracker-timeout=#{timeout}",
|
58
59
|
"--bt-stop-timeout=#{stop_timeout}",
|
60
|
+
tor_proxy_options,
|
59
61
|
sources.map { |s| "'#{s}'" }
|
60
|
-
].flatten.join(' ')
|
62
|
+
].flatten.compact.join(' ')
|
63
|
+
end
|
64
|
+
|
65
|
+
def tor_proxy_options
|
66
|
+
if use_tor_proxy
|
67
|
+
if use_tor_proxy.is_a?(String)
|
68
|
+
"--all-proxy=#{use_tor_proxy}"
|
69
|
+
else
|
70
|
+
'--all-proxy=127.0.0.1:9050'
|
71
|
+
end
|
72
|
+
end
|
61
73
|
end
|
62
74
|
|
63
75
|
end
|
data/ruby_bittorrent.gemspec
CHANGED
data/spec/bit_torrent_spec.rb
CHANGED
@@ -77,6 +77,22 @@ describe BitTorrent do
|
|
77
77
|
its(:download_commmand) { should == "aria2c --dir=/tmp --bt-enable-lpd --bt-min-crypto-level=arc4 --bt-require-crypto=true --enable-dht=true --enable-peer-exchange=true --max-overall-upload-limit=0 --seed-ratio=1.5 --seed-time=1440 --bt-tracker-connect-timeout=60 --bt-tracker-timeout=60 --bt-stop-timeout=0 '#{source}'" }
|
78
78
|
end
|
79
79
|
|
80
|
+
context "when use default tor proxy" do
|
81
|
+
let(:options) { {:use_tor_proxy => true } }
|
82
|
+
|
83
|
+
its(:use_tor_proxy) { should == true }
|
84
|
+
|
85
|
+
its(:download_commmand) { should == "aria2c --dir=. --bt-enable-lpd --bt-min-crypto-level=arc4 --bt-require-crypto=true --enable-dht=true --enable-peer-exchange=true --max-overall-upload-limit=0 --seed-ratio=1.5 --seed-time=1440 --bt-tracker-connect-timeout=60 --bt-tracker-timeout=60 --bt-stop-timeout=0 --all-proxy=127.0.0.1:9050 '#{source}'" }
|
86
|
+
end
|
87
|
+
|
88
|
+
context "when use custom tor proxy" do
|
89
|
+
let(:options) { {:use_tor_proxy => '8.8.8.8:9050' } }
|
90
|
+
|
91
|
+
its(:use_tor_proxy) { should == '8.8.8.8:9050' }
|
92
|
+
|
93
|
+
its(:download_commmand) { should == "aria2c --dir=. --bt-enable-lpd --bt-min-crypto-level=arc4 --bt-require-crypto=true --enable-dht=true --enable-peer-exchange=true --max-overall-upload-limit=0 --seed-ratio=1.5 --seed-time=1440 --bt-tracker-connect-timeout=60 --bt-tracker-timeout=60 --bt-stop-timeout=0 --all-proxy=8.8.8.8:9050 '#{source}'" }
|
94
|
+
end
|
95
|
+
|
80
96
|
context "when have 2 sources" do
|
81
97
|
let(:source2) { "magnet:?xt=urn:btih:source2" }
|
82
98
|
let(:sources) { [source, source2] }
|