ruby_bittorrent 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: adfade802f9c86624fce5934f1a9be2fe483a407
4
- data.tar.gz: acdcefda1479c172da244857065f42f3704643c1
3
+ metadata.gz: c201b204aef4f4aefdc3f52c3417681fbb29af01
4
+ data.tar.gz: ffe5c2365fe2af62db3ef5c9b54b15dc19240537
5
5
  SHA512:
6
- metadata.gz: c234f3868aecc7c25667af2402fc2a370bac363eeb614cbb55464fa4828fef7ed44686abf178f32721b9e6566408ceb096c171f2285309cc4f0387d110290a10
7
- data.tar.gz: 48bff1f530ec403bb2e53df2cff0bc1e9450f8ebedf349be33960849de8f4bb61525dbde0db86c62ff403f7d57d8d73c6f3d5f3892ccb0d4e62f4c42e5aa6736
6
+ metadata.gz: 74fac05bcc170d67a16921ae65f4291fac54d22920dc9c845f15f14888179b765b1c1d6d105b75762cb7bfacac6325601e4be245d9f51bafc6b2b44cb3def5f6
7
+ data.tar.gz: d7cb2324a86608e7c8f42dc94bebd360d851ac2d2be170877252cab14804ce3f2ad192ab93bd212b9103eb0f785fb83b922cdbfc524d96c3a46d90087b7b3d99
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby_bittorrent"
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcin Nowicki"]
@@ -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] }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_bittorrent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Nowicki