Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upHow to use the file tranfer part only #365
Comments
This comment has been minimized.
This comment has been minimized.
|
I don't understand what you mean by "only the file transfer part". Can you elaborate? What are you trying to do? |
This comment has been minimized.
This comment has been minimized.
|
Hi Thanks for your response, |
This comment has been minimized.
This comment has been minimized.
|
It's not enough that you know who has the file. They have to be seeding the file using a torrent client. If you can do that, then you're good. You'll want to disable the normal peer finding via trackers and the DHT. var client = new WebTorrent({ dht: false, tracker: false })
client.seed('/path/to/file', function (torrent) {
console.log(torrent.infoHash) // get info hash
console.log(client.torrentPort) // get torrent port
})Then from the downloader's end: var client = new WebTorrent({ dht: false, tracker: false })
var torrent = client.add(infoHash)
torrent.addPeer('ip:port') // use ip and port of remote machineHope this helps! |
This comment has been minimized.
This comment has been minimized.
|
Yes I can run the client for seeding the file as well, Thanks Alot, I will test and update here if it works. |
This comment has been minimized.
This comment has been minimized.
|
if multiple machies are hosting the same file is there any way I can pass the ip addresses of all so that it can download faster [the usuall chunk based downloading]? |
This comment has been minimized.
This comment has been minimized.
|
Just call You can specify download location with the |
This comment has been minimized.
This comment has been minimized.
|
I tried to run both instances on one machine, /Users/aliraza/node_modules/webtorrent/lib/torrent.js:385 |
This comment has been minimized.
This comment has been minimized.
|
localhost is not a valid IP address.
|
This comment has been minimized.
This comment has been minimized.
|
I tried 127.0.0.1 as well it didn't work. |
This comment has been minimized.
This comment has been minimized.
|
Ah, the downloader needs to wait until the 'infoHash' or 'listening' event before I just published a new version of WebTorrent (0.50.2) that fixes this. So update to that and try this: Seedervar WebTorrent = require('webtorrent')
var client = new WebTorrent({ dht: false, tracker: false })
client.seed('README.md', function (torrent) {
console.log(torrent.infoHash) // get info hash
console.log(client.torrentPort) // get torrent port
})Downloadervar WebTorrent = require('webtorrent')
var client = new WebTorrent({ dht: false, tracker: false })
var torrent = client.add('037596f40092d714b57a919f5628c6d3930debd0') // replace with your infohash
torrent.addPeer('127.0.0.1:52472') // replace with your port
torrent.on('done', function () {
console.log('all done!')
}) |
Hi I want to use the file transfer part only from the webtorrent, can you please guide me how to do that ?