webtorrent / webtorrent-hybrid

WebTorrent (with WebRTC support in Node.js)
https://webtorrent.io
MIT License
519 stars 98 forks source link

Get different info hash from `webtorrent-hybrid` and `webtorrent-desktop` #79

Closed zarzen closed 6 years ago

zarzen commented 6 years ago

Hi, I just noticed the info hashes created by webtorrent-desktop and webtorrent-hybrid are different. It causes a problem, when I use webtorrent-desktop created a torrent or magnet link and I also want to use servers somewhere else to seed same content to contribute the download seed, but command webtorrent-hybrid seed <the-file> won't work due to the different hash created by desktop software. Any suggestions to make it consistent hash?

feross commented 6 years ago

Thanks for reporting this. WebTorrent Desktop uses the result of the "Private" checkbox at torrent creation time to set the torrent's private flag to true or false. Unfortunately, there's an issue with the way this private flag spec was designed. There are actually 3 possible values for the private flag:

The problem is that private flag is part of the info section in the .torrent file, which means that each of these three values for private will produce a different info hash.

So, what's happening is that webtorrent-cli and webtorrent-hybrid are not setting private at all, while WebTorrent Desktop is setting it to false.

I submitted a PR to fix this in WebTorrent Desktop: https://github.com/webtorrent/webtorrent-desktop/pull/1411

feross commented 6 years ago

As a temporary workaround until a new version of WebTorrent Desktop is released, you can create a torrent from the command line that matches the WebTorrent Desktop one by explicitly setting private to false like this:

create-torrent --no-private ~/test-files/cat.jpg > ~/Desktop/cat.torrent