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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Add IPv6 DHT support #5

wants to merge 9 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.


k-rpc specific notes:

As this repository does more than k-rpc-socket, this PR is more involve than the k-rpc-socket pr. Like in k-rpc-socket, I add an ipv6 parameter to control if a k-rpc instance is used for IPv4 or IPv6. Most of the changes are for implementing the encoding/decoding of IPv6 nodes, as specified in BEP 32. As in k-rpc, I use a wrapper functions to run the tests with IPv4 and IPv6 rpc instances without duplicating code.

Notes:

Caveats:

  • This line could probably be made more efficient, but I didn't think that it was necessary.
  • Unfortunately, I've only been able to find one public IPv6 DHT server (with a permanent domain name - there are of course many peers on the network) - the other two used as IPv4 DHT nodes don't even have AAAA DNS records. If anyone knows of any other IPv6 DHT bootstrap nodes, I'd be happy to add them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant