Closed allhailjarjar closed 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.
Okay I just read the DHT part of https://geti2p.net/en/docs/applications/bittorrent, I see why you've approached it like this.
I came up with a significantly simpler solution. I'll make a new PR soon with those changes
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.