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

What is the proper way to host a server on both IPv4 and IPv6? #510

Open
Your-New-SJW-Waifu opened this issue Jan 3, 2021 · 8 comments
Open

Comments

@Your-New-SJW-Waifu
Copy link

There's the addr: field but it doesn't seem to accept an array so I'm not entirely sure how I'm supposed to bind to both IPv4 and IPv6 with the same instance. Any help would be appreciated.

@mrd0ll4r
Copy link
Member

mrd0ll4r commented Jan 3, 2021

You can set 0.0.0.0:<port> or (probably, haven't tested) just :<port> and it will listen on all interfaces :)

@Your-New-SJW-Waifu
Copy link
Author

:<port>

Wow I completely forgot about that. Now I feel dumb. Let me test that.

@Your-New-SJW-Waifu
Copy link
Author

Yeah, no. That doesn't work. I can set [<IPv6>]:<port> and then IPv6 works but then I lose IPv4. 0.0.0.0:<port>, :<port>, and bizarrely enough [::]:<port> all seem to only bind to IPv4.
That being said, ideally I don't want it running on all addresses. It'd be nice to have an array to be able to specify addresses to bind to.

@jzelinskie
Copy link
Member

jzelinskie commented Jan 6, 2021

See golang/go#9334

I suspect writing something that muxes net.Listeners would have a significant performance impact.
We could accept a list of addresses and create an instance of a frontend for each.

@Your-New-SJW-Waifu
Copy link
Author

That makes sense. I guess one workaround would be to have two seperate instances that share a redis database to share peers. I feel like that'd impact performance a lot.

Still, that doesn't really seem to explain why :<port> isn't working.

I hadn't tested this but I just thought of this and I wonder if it is binding to IPv6 but somewhere along the line it's defaulting to IPv4 so it's expecting IPv4 but getting IPv6 with some connections and returning an error or something.

@Aranjedeath
Copy link

I run totally separate copies of the software for my public ipv4/ipv6 addresses. It works well, but my tracker is totally public. Hopefully PEX is doing some work for me here.

@mrd0ll4r
Copy link
Member

I actually think that's not a bad approach. IPv4 clients can only talk to other IPv4 clients, and vice versa for IPv6. There's the IPv4-in-IPv6 addresses, but afaik that's just syntactic sugar done by the OS to make it easier to develop IPv6-only applications.

Running two instances has a tiny and constant memory overhead for some data structures, but I wouldn't be surprised if it performed on par or even better than one monolithic tracker with two frontends. We could optimize this case by differentiating between IPv4 and IPv6 storage implementations to potentially save 16 bytes per peer per swarm.

@Aranjedeath
Copy link

Yeah I guess if you are only listening on one type of address, that could be communicated to the storage layer. I don't know if that matters in practice. Envelope math says I'd save 100 megabytes of ram on the v4 instance (5 million peers+seeds * 16 bytes).

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

No branches or pull requests

4 participants