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

Default to IPv6 bind address #566

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

belohnung
Copy link

Default to IPv6 bind address

  • By default applications should listen to the ipv6 wildcard address as this also includes IPv4 addresses and enables IPv6 support

Solution

  • The default bind ip address was set to the UNSPECIFIED constant of IPv6Adress

@dyc3
Copy link
Collaborator

dyc3 commented Oct 16, 2023

IIRC, this port binding behavior is only applicable to Linux. Does it do the same thing on Windows and Mac?

@dyc3
Copy link
Collaborator

dyc3 commented Oct 21, 2023

It appears that on windows, this PR will make it so that it only binds to ipv6, and not both.

Source: https://learn.microsoft.com/en-us/windows/win32/winsock/dual-stack-sockets#creating-a-dual-stack-socket

@belohnung
Copy link
Author

My bad. Could we set those sock opts so that the behavior matches?

@dyc3
Copy link
Collaborator

dyc3 commented Oct 31, 2023

You tell me, this is your PR.

@belohnung
Copy link
Author

It really sucks that the behavior is not uniform. With a quick search i also did not find a way to set a sockopt on the TcpListener.. Perhaps we could default to IPv6 on Linux only for now?

@dyc3
Copy link
Collaborator

dyc3 commented Nov 2, 2023

I think you could create a std::net::TcpListener to set up the socket then use https://docs.rs/tokio/latest/tokio/net/struct.TcpListener.html#method.from_std to turn it into a tokio socket.

this might also help: https://docs.rs/net2/latest/net2/struct.TcpBuilder.html#method.only_v6

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.

None yet

2 participants