--------------050001040906020902030309 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Florian Gross wrote: > Here we go. Thanks to Mauricio FernáÏdez for helping out with cutting > off a few important characters! Another new version, binary files can be transfered to and from Win32, you can run servers from behind Routers and you can list all the files on the specified network sorted by node and file name before downloading them. Still six lines. --------------050001040906020902030309 Content-Type: text/plain; name="p2p.rb" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="p2p.rb" #!/usr/bin/ruby # Server: ruby p2p.rb password server public-uri private-uri merge-servers # Sample: ruby p2p.rb foobar server druby://123.123.123.123:1337 # druby://:1337 druby://foo.bar:1337 # Client: ruby p2p.rb password client server-uri download-pattern [list-only] # Sample: ruby p2p.rb foobar client druby://localhost:1337 *.rb ################################################################################ require'drb';F=File;P,M,U,V,*O=ARGV;def c(u)DRbObject.new((),u)end;def x(u);[P,u ].hash;end;def s(p);F.basename p[/[^|]+/];end;M["s"]?(DRb.start_service V,Class. new{def p(z=O)O.push(*z).uniq;end;new.methods.map{|m|m[/_[_t]/]||private(m)};def y;(p(U)+p).map{|u|u!=U&&c(u).f(x(u),p(U))};self;end;def f(c,a=[],t=2)x(U)==c&&t< 1?Dir[s(a)]:t<2?[*open(s(a),"rb")]:p(a)end}.new.y;sleep):c(U).f(x(U)).map{|n|c(n ).f(x(n),V,0).map{|f|s f}.sort.map{|f|O[0]?p(f):open(f,"wb")<<c(n).f(x(n),f,1)}} --------------050001040906020902030309--