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 #27

Closed
wants to merge 5 commits into from
Closed

Add IPv6 DHT support #27

wants to merge 5 commits into from

Conversation

Aaron1011
Copy link

@Aaron1011 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.


torrent-discovery specific notes:

This PR allows torrent-discovery to handle up to two DHT instances, one for each IP version used. To control the IPv6 instance, I've added a dht6 parameter to the constructor, which behaves in exactly the same way as the regular dht parameter. As always, tests are wrapped in order to be run for either IPv4 and IPv6. I've added a separate test to exercise both simultaneously.

Notes:

  • Peers are emitted the same, regardless of which DHT instance they come from. Since users of this library already need to be able to handle IPv4 and IPv6 peers (since bittorrent-dht supports IPv4 and IPV6 trackers), this should be fine.

Caveats:

  • This code is fairly ugly, but it prevents quite a bit of copy-pasting. If it's too unreadable, I can change it to a more verbose but less complicated implementation.

@DiegoRBaquero
Copy link
Member

Stale, will close in month if nothing happens.

@DiegoRBaquero DiegoRBaquero self-requested a review June 1, 2021 03:07
@DiegoRBaquero DiegoRBaquero self-assigned this Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants