quartz_torrent 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/.yardopts +1 -0
  2. data/README.md +111 -0
  3. metadata +3 -1
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --readme README.md
data/README.md ADDED
@@ -0,0 +1,111 @@
1
+ QuartzTorrent -- A Ruby Bittorrent Library
2
+ ==========================================
3
+
4
+ Like the title says, a bittorrent library implemented in pure ruby. Currently
5
+ the library works, but is still alpha.
6
+
7
+ Features:
8
+ ---------
9
+
10
+ - BEP 9: Extension for Peers to Send Metadata Files
11
+ - BEP 10: Extension Protocol
12
+ - BEP 15: UDP Tracker support
13
+ - BEP 23: Tracker Returns Compact Peer Lists
14
+ - Upload and download rate limiting
15
+ - Upload ratio enforcement
16
+
17
+ Requirements
18
+ ------------
19
+
20
+ This library has been tested with ruby1.9.1. The required gems are listed in the gemspec.
21
+
22
+ Running the curses client requires rbcurse-core (0.0.14).
23
+
24
+ Getting Started
25
+ ---------------
26
+
27
+ How to use the library is best illustrated with an example. The sample program below touches on all the
28
+ major ideas.
29
+
30
+ require 'quartz_torrent'
31
+ include QuartzTorrent
32
+
33
+ # Direct logging to stdout at info level
34
+ LogManager.setup do
35
+ setLogfile "stdout"
36
+ setDefaultLevel :info
37
+ end
38
+
39
+ # When CTRL-C is pressed, shut down
40
+ running = true
41
+ Signal.trap('SIGINT') do
42
+ puts "Got SIGINT. Shutting down."
43
+ running = false
44
+ end
45
+
46
+ # Create MagnetURI from first argument
47
+ magnet = MagnetURI.new(ARGV[0])
48
+
49
+ # Create a PeerClient that downloads to the current directory.
50
+ # This is the main API, and implements the Bittorrent peer protocol.
51
+ peerclient = PeerClient.new(".")
52
+ peerclient.port = 5555
53
+ peerclient.addTorrentByMagnetURI magnet
54
+
55
+ # Start the peerclient in another thread.
56
+ peerclient.start
57
+
58
+ while running do
59
+ peerclient.torrentData.each do |infohash, torrent|
60
+ name = torrent.recommendedName
61
+ pct = 0
62
+ if torrent.info
63
+ pct = (torrent.completedBytes.to_f / torrent.info.dataLength.to_f * 100.0).round(2)
64
+ end
65
+ puts "#{name}: #{pct}%"
66
+ end
67
+ sleep 2
68
+ end
69
+
70
+ peerclient.stop
71
+
72
+ Logging is configured using QuartzTorrent::LogManager. Logs can be sent to stdout, stderr, or file. Individual loggers can be set to different levels.
73
+
74
+ The QuartzTorrent::PeerClient class is the main interface for downloading and uploading torrents. The PeerClient constructor takes the path to the
75
+ directory into which torrents should be downloaded. Torrents may be added to the PeerClient as Magnet links, or .torrent file contents before or after
76
+ the PeerClient is stared. When started, the PeerClient runs asynchronously in a separate thread. Information regarding the running torrents is retrieved
77
+ with the PeerClient::torrentData method.
78
+
79
+ More elaborate examples can be found in `bin/quartztorrent_download` and `bin/quartztorrent_download_curses`.
80
+
81
+ Running Tests
82
+ -------------
83
+
84
+ Run the tests as:
85
+
86
+ rake test
87
+
88
+ You can run a specific test using, i.e.:
89
+
90
+ rake test TEST=tests/test_reactor.rb
91
+
92
+ And a specific test case in a test using:
93
+
94
+ ruby1.9.1 -Ilib tests/test_reactor.rb -n test_client
95
+
96
+
97
+ To-Do
98
+ -----
99
+ - Start a peerclient with the full torrent. Connect with another peerclient and start downloading, then pause.
100
+ Finally unpause. The "server" peerclient will refuse the connections to re-establish because it believes the
101
+ peer is already connected.
102
+ - Improve CPU usage.
103
+ - Implement endgame strategy and support Cancel messages.
104
+ - Refactor Metadata.Info into it's own independent class.
105
+ - Improve Documentation
106
+ - In peerclient, prefix log messages with torrent infohash, or (truncated) torrent name
107
+ - Implement uTP
108
+ - <http://www.bittorrent.org/beps/bep_0029.html#packet-sizes>
109
+ - <https://forum.utorrent.com/viewtopic.php?id=76640>
110
+ - <https://github.com/bittorrent/libutp>
111
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quartz_torrent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -163,6 +163,8 @@ files:
163
163
  - lib/quartz_torrent/filemanager.rb
164
164
  - lib/quartz_torrent/magnet.rb
165
165
  - lib/quartz_torrent/udptrackerclient.rb
166
+ - README.md
167
+ - .yardopts
166
168
  - bin/quartztorrent_download
167
169
  - bin/quartztorrent_download_curses
168
170
  - bin/quartztorrent_magnet_from_torrent