Generate webseeded torrent files from urls to files.
##Background Knowledge Webseeding means to use servers as bittorrent clients, simulating piece requests using range requests (which the server must support). This is mostly benefitial for bootstrapping swarms.
There are very particular requirements on your server's file paths. The torrent name must be a common segment of all file urls, so each url is constructed by combining the base, the torrent name, and the file name.
If you wish to create a torrent out of the three following urls:
Then you must specify the following arguments:
var base = '';var name = 'jj2005-02-27.fm.shnf';var files ='jj2005-02-27.fm.d1.md5''jj2005-02-27.fm.d1.txt';
Warning: The base must end with
/, while the name and the files must not.
var Torrent = require'webseeded-torrent-generator';var base = '';var name = 'jj2005-02-27.fm.shnf';var files ='jj2005-02-27.fm.d1.md5''jj2005-02-27.fm.d1.txt';var torrent = base name files;// if you want to write out .torrent files, do thistorrentgetMetadatathenfswriteFileSync'tmp.torrent' buf;;// if you want to serve up .torrent files via express,// do something like the following (assuming we have request/result objects)torrentgetMetadatathenresulttype'application/x-bittorrent';resultattachmentname + '.torrent';resultsend200 buf;;