Skip to content

Default to IPv6 bind address#566

Open
belohnung wants to merge 3 commits into
valence-rs:mainfrom
belohnung:patch-1
Open

Default to IPv6 bind address#566
belohnung wants to merge 3 commits into
valence-rs:mainfrom
belohnung:patch-1

Conversation

@belohnung

Copy link
Copy Markdown

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

dyc3 commented Oct 16, 2023

Copy link
Copy Markdown
Collaborator

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

@dyc3

dyc3 commented Oct 21, 2023

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Author

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

@dyc3

dyc3 commented Oct 31, 2023

Copy link
Copy Markdown
Collaborator

You tell me, this is your PR.

@belohnung

Copy link
Copy Markdown
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

dyc3 commented Nov 2, 2023

Copy link
Copy Markdown
Collaborator

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.

2 participants