holepunchto / hyperdht

The DHT powering Hyperswarm
https://docs.holepunch.to
MIT License
333 stars 49 forks source link

Support IPv6 #1

Open hackergrrl opened 6 years ago

hackergrrl commented 6 years ago

related: https://github.com/webtorrent/bittorrent-dht/issues/88

RangerMauve commented 5 years ago

This would be super useful for a project I'm working on.

Would a PR that adds support be welcome?

makew0rld commented 5 years ago

@mafintosh @aral @pfrazee Is supporting IPv6 here and across hyperswam a possibility? It would be really helpful for IPv6 networks such as meshnets, and as the Internet evolves.

RangerMauve commented 4 years ago

Sadly I haven't had time for this.

From talking to @mafintosh in the past it seems the first step would be to make an equivalent of ipv4-peers for ipv6 peers.

If someone could implement this it could be the first step for getting ipv6 to work.

After that it'd be good to set up an ipv6 DHT bootstrap node and make an example of initializing the DHT with the ipv6-peers encoding / figuring out how to do that at the hyperswarm level.

kravietz commented 4 years ago

@mafintosh @RangerMauve The main driver for having IPv6 is user experience and network performance. Getting any P2P network to operate behind NAT is a pain and if you ever ran tcpdump on most P2P nodes (like IPFS or SSB) you surely have seen how many connections attempts are being made towards RFC 1918 networks which other NATed nodes announce, and effectively wasted. I run BitTorrent and IPFS over IPv6 for a few years now and it just works like a breeze. For DAT to even work I need to create awkward port forwards or run an additional proxy node on my router to be able to talk both to NAT and other nodes on the Internet.

If this is purely matter of resources, maybe we can do some crowdsourcing on Bountysource, Gitcoin or something like that?

RangerMauve commented 4 years ago

Part of the issue is that the tech leads for hyperswarm don't use IPv6 in their day to day so it's a bit harder for them to integrate it. I think also with regards to all the other things on the TODO list this just isn't a high priority item.

I don't think I have time to implement stuff at the moment but I'm willing to donate some time to mentor somebody else that wants to start putting it together and submitting a PR.

RangerMauve commented 4 years ago

It might be useful to talk about this more at the next dat comm comm https://github.com/datproject/comm-comm/issues/136

pfrazee commented 4 years ago

Maf can give a better explanation, but my understanding is that we started with IPv4 because it has the largest adoption so it's wise to make that work first. Hyperswarm's DHT includes hole-punching specifically to handle NATs and success rates have been very high so far.

IPv6 is on the roadmap but it's not trivial to implement because it introduces duplicate addresses for each peer, and so the network has to include logic to avoid creating duplicate connections. The decision was to prioritize IPv4's success-rate before putting resources into implementing IPv6.

makew0rld commented 4 years ago

An alternate way of approaching this would be through webtorrent/bittorrent-dht#88, where there are already PRs to add IPv6 to the whole dat ecosystem.

RangerMauve commented 4 years ago

@makeworld-the-better-one I don't think hyperswarm is using the bittorrent DHT anymore so it probably won't be enough. 😅

martinheidegger commented 4 years ago

Just to share here: https://dat.discourse.group/t/where-is-dat-on-ipv6-support/32/4

urbien commented 4 years ago

I run BitTorrent and IPFS over IPv6 for a few years now and it just works like a breeze.

@kravietz can you elaborate on that? Do you mean that by using IPv6 you bypass NAT? I understand that NAT was introduced initially as a way to multiplex local addresses onto the limited IPv4 address space. But now everyone is sitting behind NAT. How does IPv6 helps? Is there any way to configure NAT to pass-through the IPv6 traffic, or are you saying this is what NAT does by default?

kravietz commented 4 years ago

@urbien

When you're on IPv4 a typical set up will be like this:

On IPv6 large part of this complexity is gone:

In other words, with IPv4 your gateway is a NAT translation box that needs to be configured to pass-through specific traffic. With IPv6 your gateway is simply a router that has a simple job of routing traffic between public subnets without any additional configuration.

mafintosh commented 3 years ago

Upcoming v5 has primitives to connect peers over ipv6

RangerMauve commented 3 years ago

@mafintosh Is there some code I could look at to check it out? :O

perguth commented 9 months ago

Close? https://github.com/holepunchto/hyperdht/blob/2e9c6b613340b996e0d26a19e5b86500d5bae0bc/lib/messages.js#L17