Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only seed to Browser #1626

Closed
Fenny opened this issue May 8, 2019 · 2 comments
Closed

Only seed to Browser #1626

Fenny opened this issue May 8, 2019 · 2 comments

Comments

@Fenny
Copy link

@Fenny Fenny commented May 8, 2019

What version of WebTorrent?
0.103.1 Webtorrent-hybrid
What operating system and Node.js version?
Windows 10 (64-bit) Nodejs v10.15.3 (64-bit)
What browser and version? (if using WebTorrent in the browser)
Chrome Version 74.0.3729.131 (Official Build) (64-bit)
What did you expect to happen?
Seed only to WebRTC peers, disable UDP seeding on adding a torrent
What actually happened?
Seeds to both WebRTC and UDP

Hi all,

I know it's normal to seed when adding a torrent and keep the download/upload ratio above 1.0.
This is fine, but when the torrent files are 100% downloaded, I would like to continue seeding the files with the same hash but only to WebRTC clients.

Is there a way to block UDP leechers / seeders when the torrent is 100% finished?

I also tried to delete the torrent and use the Client.seed function with a private tracker in the announce, but webtorrent keeps adding the default trackers as stated in this issue Issue 1604 plus the torrent hash is different than the one we started with ( not sure if it's possible to create the same magnet with the .seed function )

Could anyone point me in the right direction?

Thanks!

@AyrA

This comment has been minimized.

Copy link

@AyrA AyrA commented Jun 10, 2019

That's a tricky situation. When a regular client downloads all odd pieces and a web client downloads all even pieces it looks like there's a 1.0 ratio, but if you stop seeding to regular torrent clients now they will never be able to complete unless the other webclient can send them data.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Sep 7, 2019

Making the torrent "private" will change it's info hash. That's by design. This is not what you want to use.

To disable non WebRTC peers, you can disable the DHT (since no WebRTC peers come from that):

{ dht: false }

You should also remove all tracker servers that are not prefixed with wss: or ws:. If you're using client.seed to seed a new torrent, you can do this:

const WebTorrent = require('webtorrent')
const createTorrent = require('create-torrent')

const websocketTrackers = createTorrent.announceList.filter(url => url.startsWith('ws'))

const client = new WebTorrent()
const torrent = client.seed(file, {
  announce: websocketTrackers,
  dht: false
})

That should do it.

But if you're using webtorrent-hybrid instead of webtorrent, then you'll run into the bug you described in #1604 where default trackers always get added.

You should be able to fix that by overwriting global.WEBTORRENT_ANNOUNCE. So the final code would be:

const WebTorrent = require('webtorrent-hybrid')
const createTorrent = require('create-torrent')

global.WEBTORRENT_ANNOUNCE = []
const websocketTrackers = createTorrent.announceList.filter(url => url.startsWith('ws'))

const client = new WebTorrent()
const torrent = client.seed(file, {
  announce: websocketTrackers,
  dht: false
})
@feross feross closed this Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.