anacrolix / dht

dht is used by anacrolix/torrent, and is intended for use as a library in other projects both torrent related and otherwise
Mozilla Public License 2.0
313 stars 66 forks source link

WIP: First attempt at adding i2p support #55

Closed allhailjarjar closed 2 years ago

allhailjarjar commented 2 years ago

This is a WIP attempt at adding I2P support.

This is a follow up to the discussion here: https://github.com/anacrolix/torrent/issues/705

It uses go's new generics to abstract the type for CompactIPv4NodeInfo struct. I'm not a huge fan of it because it requires so much modification but I thought for a couple of days about this, and I wasn't able to come up with a better solution.

The biggest obstacle and what makes this complicated is "Nodes" field in the krpc.Return struct must work for both IP addresses and I2P addresses. Since Go is statically typed and the way the binary decoding must happen, it makes it complicated.

Maybe you can advise on a simpler solution, because I'm running out of ideas to try here. Or maybe you're a fan of this approach, please let me know.

anacrolix commented 2 years ago

Yeah this doesn't feel right, it's valid to return multiple types of node info in a message, so if there's a field reserved for i2p, it should just be added alongside the IPv4 and IPv6 ones.

anacrolix commented 2 years ago

Okay I just read the DHT part of https://geti2p.net/en/docs/applications/bittorrent, I see why you've approached it like this.

allhailjarjar commented 2 years ago

I came up with a significantly simpler solution. I'll make a new PR soon with those changes