[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] rubytorrent 0.1 (bittorrent for ruby

William Morgan

1/4/2005 5:00:00 AM

Hello all,

I'm happy to release RubyTorrent 0.1. RubyTorrent is a pure-Ruby
BitTorrent peer library. Changes in version 0.1 include many bugfixes
(Windows platforms now fully functional) and enhancements (snubbing
support, API improvements, http_proxy). You can get it at:

http://www.masanjin.net/~wmorgan/rubytorrent/rubytorrent-...
(RubyForge project coming soon.)

RubyTorrent is around 1500 lines. I've included a simple command-line
text peer program, rtpeer.rb, for you to play around with. The API is
also slowly changing into something useful. From the "docs":

Synopsis
--------

## world's smallest bittorrent client
require 'rubytorrent'
bt = RubyTorrent::BitTorrent.new(ARGV.shift)
thread = Thread.new do
while true
puts bt.percent_completed
sleep 15
end
end
bt.on_complete { thread.kill }
thread.join

Comments, bug reports and patches always welcome. Have fun.

--
William <wmorgan-ruby-talk@masanjin.net>


4 Answers

Tobias Luetke

1/4/2005 9:05:00 AM

0

Awesome project.

Thank you so much. this will be very valuable

On Tue, 4 Jan 2005 13:59:56 +0900, William Morgan
<wmorgan-ruby-talk@masanjin.net> wrote:
> Hello all,
>
> I'm happy to release RubyTorrent 0.1. RubyTorrent is a pure-Ruby
> BitTorrent peer library. Changes in version 0.1 include many bugfixes
> (Windows platforms now fully functional) and enhancements (snubbing
> support, API improvements, http_proxy). You can get it at:
>
> http://www.masanjin.net/~wmorgan/rubytorrent/rubytorrent-...
> (RubyForge project coming soon.)
>
> RubyTorrent is around 1500 lines. I've included a simple command-line
> text peer program, rtpeer.rb, for you to play around with. The API is
> also slowly changing into something useful. From the "docs":
>
> Synopsis
> --------
>
> ## world's smallest bittorrent client
> require 'rubytorrent'
> bt = RubyTorrent::BitTorrent.new(ARGV.shift)
> thread = Thread.new do
> while true
> puts bt.percent_completed
> sleep 15
> end
> end
> bt.on_complete { thread.kill }
> thread.join
>
> Comments, bug reports and patches always welcome. Have fun.
>
> --
> William <wmorgan-ruby-talk@masanjin.net>
>
>


--
Tobi
http://www.h... - Open source book authoring
http://blog.le... - Technical weblog


martinus

1/4/2005 10:34:00 AM

0

Great work, thanks!

martinus

Paul Duncan

1/4/2005 9:24:00 PM

0

* William Morgan (wmorgan-ruby-talk@masanjin.net) wrote:
> Hello all,
>
> I'm happy to release RubyTorrent 0.1. RubyTorrent is a pure-Ruby
> BitTorrent peer library. Changes in version 0.1 include many bugfixes
> (Windows platforms now fully functional) and enhancements (snubbing
> support, API improvements, http_proxy). You can get it at:
>
> http://www.masanjin.net/~wmorgan/rubytorrent/rubytorrent-...
> (RubyForge project coming soon.)
>
> RubyTorrent is around 1500 lines. I've included a simple command-line
> text peer program, rtpeer.rb, for you to play around with. The API is
> also slowly changing into something useful. From the "docs":

Hi William,

It looks like you can add support for remote torrents by changing two
lines. Here's a diff (I'm sending it to the list for discussion):

--
diff -ur rubytorrent-0.1/rubytorrent/metainfo.rb rubytorrent-0.1-openuri/rubytorrent/metainfo.rb
--- rubytorrent-0.1/rubytorrent/metainfo.rb 2005-01-03 23:47:48.000000000 -0500
+++ rubytorrent-0.1-openuri/rubytorrent/metainfo.rb 2005-01-04 16:01:08.000000000 -0500
@@ -1,5 +1,6 @@
require 'rubytorrent/typedstruct'
require 'uri'
+require 'open-uri'
require 'digest/sha1'

## MetaInfo file is the parsed form of the .torrent file that people
@@ -164,7 +165,7 @@
end

def self.from_filename(fn)
- File.open(fn, "rb") { |f| from_bstream(BStream.new(f)) }
+ open(fn, "rb") { |f| from_bstream(BStream.new(f)) }
end

def self.from_stream(fn)
--

With this change, RubyTorrent can then handle URIs to torrent files transparently, like so:

bt = RubyTorrent::BitTorrent.new('http://www.legaltorrents.com/bit/wired-creative-commons-cd.to...)

Hope this helps...

> Synopsis
> --------
>
> ## world's smallest bittorrent client
> require 'rubytorrent'
> bt = RubyTorrent::BitTorrent.new(ARGV.shift)
> thread = Thread.new do
> while true
> puts bt.percent_completed
> sleep 15
> end
> end
> bt.on_complete { thread.kill }
> thread.join
>
> Comments, bug reports and patches always welcome. Have fun.

--
Paul Duncan <pabs@pablotron.org> pabs in #ruby-lang (OPN IRC)
http://www.pabl... OpenPGP Key ID: 0x82C29562

William Morgan

1/5/2005 3:31:00 PM

0

Excerpts from Paul Duncan's mail of 4 Jan 2005 (EST):
> It looks like you can add support for remote torrents by changing two
> lines. Here's a diff (I'm sending it to the list for discussion):

Thanks. I'll incorporate that in in 0.2.

--
William <wmorgan-ruby-talk@masanjin.net>