chr15m / bugout

Back end web app services over WebRTC.
https://chr15m.github.io/bugout
MIT License
607 stars 59 forks source link

"private" option for the seeded communication path #19

Closed neuronsupport closed 4 years ago

neuronsupport commented 4 years ago

"private" option for the seeded communication path needs to be offered in constructor.

chr15m commented 4 years ago

@norzak sounds interesting - can you explain in more detail what you mean by this? Do you mean passing in private trackers? Or a shared secret for encryption?

bertung commented 4 years ago

There is an option in web torrent API to make the seeding private so that it wont be made available to others by the trackers. This way a communication may be more secure.

chr15m commented 4 years ago

@bertung ah, that's cool. Will investigate, and if you've got any links post them here.

chr15m commented 4 years ago

@bertung I can't find mention of the word "private" on the API page, can you link me to what you mean?

bertung commented 4 years ago

@chr15m Interesting, according to this https://github.com/webtorrent/webtorrent/issues/386 there is a "private" option. May be the API doc is not updated? Let me check the webtorrent code.

bertung commented 4 years ago

There is private option in the code but not documented. They probably forgot to update the docs.

/**
 * Create a torrent.
 * @param  {string|File|FileList|Buffer|Stream|Array.<string|File|Buffer|Stream>} input
 * @param  {Object} opts
 * @param  {string=} opts.name
 * @param  {Date=} opts.creationDate
 * @param  {string=} opts.comment
 * @param  {string=} opts.createdBy
 * @param  {boolean|number=} opts.private
 * @param  {number=} opts.pieceLength
 * @param  {Array.<Array.<string>>=} opts.announceList
 * @param  {Array.<string>=} opts.urlList
 * @param  {Object} opts.info
 * @param  {function} cb
 * @return {Buffer} buffer of .torrent file data
 */
function createTorrent (input, opts, cb) {
  if (typeof opts === 'function') [opts, cb] = [cb, opts]
  opts = opts ? Object.assign({}, opts) : {}

  _parseInput(input, opts, (err, files, singleFileTorrent) => {
    if (err) return cb(err)
    opts.singleFileTorrent = singleFileTorrent
    onFiles(files, opts, cb)
  })
}
chr15m commented 4 years ago

After reviewing this I realized it isn't in the WebTorrent API documentation because it's an option that gets passed through to the underlying create torrent call. I started working on a facility to allow options to be passed through to the seed() call too so that private can be passed in that way. Thanks for alerting me to this.

bertung commented 4 years ago

There is a recent commit at Webtorrent side.

https://github.com/webtorrent/webtorrent/pull/1819

chr15m commented 4 years ago

Working on an update.

chr15m commented 4 years ago

Hey, it should be possible to pass the private option, and other options, via torrentOpts now. Can you guys let me know if this looks ok?

https://github.com/chr15m/bugout/blob/master/docs/API.md#options https://github.com/chr15m/bugout/blob/master/docs/API.md#private-torrents

bertung commented 4 years ago

Yes, it sounds great. thanks for this.

neuronsupport commented 4 years ago

Perfect.

bertung commented 4 years ago

Wait, private option is not for webtorrent object it is for add and seed methods. With this change, we can add private option to seed, but not the add. Passing private to webtorrent object has no effect.

https://github.com/webtorrent/webtorrent/blob/master/docs/api.md#clientseedinput-opts-function-onseed-torrent-

bertung commented 4 years ago

This is the add method. But add is not used by bugout. Therefore, this change solves the problem, but it is not really needed for web torrent object.

https://github.com/webtorrent/webtorrent/blob/master/docs/api.md#clientaddtorrentid-opts-function-ontorrent-torrent-

bertung commented 4 years ago

Basically you can ignore my last two comments :)