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

Add IPv6 DHT support #950

Open
wants to merge 3 commits into
base: master
from
Open

Add IPv6 DHT support #950

wants to merge 3 commits into from

Conversation

@Aaron1011
Copy link

Aaron1011 commented Oct 17, 2016

k-rpc-socket | k-rpc | bittorrent-dht | torrent-discovery | webtorrent

This is one of many pull requests across the WebTorrent ecosystem to add IPv6 DHT support, as per webtorrent/bittorrent-dht#88

Per the BEP 32 statement about maintaining distinct IPv4/IPv6 DHTs and the discussion on webtorrent/bittorrent-dht#88, my implementation requires separate instances of bittorrent-dht and everything below it on the protocol stack (k-rpc and k-rpc-socket). torrent-discovery maintains up to two DHT instances, one for each IP version used. Fortunately, WebTorrent already supports IPv6 peers, so no changes are needed in it beyond properly using the IPv6 DHT, if enabled in the options.

The best way to run all of my changes is by using the npm link command. Assuming that all of the necessary modules (k-rpc-socket, k-rpc, bittorrent-dht, torrent-discovery, webtorrent, and webtorrent-cli are sibling directories, the following commands will set things up properly (starting from the parent directory):

cd k-rpc-socket
npm install
npm link
cd ../k-rpc
npm install
npm link k-rpc-socket
npm link
cd ../bittorrent-dht
npm install
npm link k-rpc
npm link
cd ../torrent-discovery
npm install
npm link bittorrent-dht
npm link
cd ../webtorrent
npm install
npm link bittorrent-dht
npm link torrent-discovery
npm link
cd ../webtorrent-cli
npm install
npm link webtorrent

From there, you can test and run individual modules as you choose.


webtorrent specific notes:

This PR bring together all of my changes across the other repositories, allowing IPv6 DHT support to actually be used :).

I've added a new dht6 option, which functions in the same way as the already existent dht option does.

Notes:

  • The changes needed here were minimal - I store the IPv6 DHT instance in the same way that the IPv4 one is stored, and ensure the PORT messages are handled using the correct protocol. Nearly all of the changes are to tests - for ones which disable DHT, I make sure to disable the IPv6 DHT as well.

Caveats:

  • The dht port is always shared between the IPv4 and IPv6 DHT instances. My rationale for this is that the port will usually kept constant between DHT instances - changing the port implies a conceptually separate. However, I can change this if necessary.
  • webtorrent-cli and webtorrent-desktop don't expose any way to selectively enable either the IPv4 DHT or the IPv6 DHT (thought it can be done through the API). However, I don't anticipate this being a very common usecase.

Running the implementation:

No direct changes are needed to webtorrent-cli or webtorrent-desktop are needed to run this. Since you can't really see any results with webtorrent-desktop (neither the peer list nor DHT information is shown), webtorrent-cli should be used to test this.

The following steps describe how to best test the IPv6 DHT with webtorrent-cli:

  1. Ensure that all of the modules are properly linked, as described at the top of the issue.
  2. From the webtorrent-cli directory, run DEBUG=torrent-discovery bin/cmd.js download bf6f2be549a8aca5776638b59b2bca53d7bbc748. (the infohash is for ubuntu-16.10-server-amd64.iso) You should see lots of peer message being printed out to the console, many containing IPv6 addresses.

As a side note, you can use only IPv6 peers (both tracker and DHT) by using a blocklist containing this line: Whole IPV4-Internet:1.1.1.1-224.0.0.0. This can be enabled with the --blocklist flag. With the blocklist saved to blocklist.txt in the root of the project, the command would look like this:

DEBUG=torrent-discovery bin/cmd.js download bf6f2be549a8aca5776638b59b2bca53d7bbc748 --blocklist blocklist.txt

Aaron1011 added 3 commits Oct 17, 2016
@Aaron1011

This comment has been minimized.

Copy link
Author

Aaron1011 commented Oct 21, 2016

@feross: Are there any changes you need me to make to this?

@stale stale bot added the stale label May 3, 2018
@webtorrent webtorrent deleted a comment from stale bot May 3, 2018
@stale stale bot removed the stale label May 3, 2018
@stale

This comment has been minimized.

Copy link

stale bot commented Aug 2, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Aug 2, 2018
@stale stale bot closed this Aug 9, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Nov 7, 2018
@feross feross reopened this Aug 5, 2019
@stale stale bot removed the stale label Aug 5, 2019
@webtorrent webtorrent unlocked this conversation Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.