-
Notifications
You must be signed in to change notification settings - Fork 7
Use IPV6_V6ONLY flag to avoid dualstack binding #116
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements the IPV6_V6ONLY flag for socket creation to avoid dualstack binding for both TCP and UDP servers. Key changes include:
- Introducing the create_udp_socket function in udp.rs to enforce IPV6_V6ONLY for UDP sockets.
- Introducing the create_tcp_listener function in tcp.rs with IPV6_V6ONLY support for TCP sockets.
- Adding the socket2 dependency in Cargo.toml to support advanced socket option configuration.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
taxy/src/server/udp.rs | Replaces direct binding with a custom function that sets IPV6_V6ONLY. |
taxy/src/server/tcp.rs | Uses a custom listener creation function with IPV6_V6ONLY enforcement; note the minimal listen backlog. |
taxy/Cargo.toml | Adds the socket2 dependency required for the new socket configuration. |
taxy/src/server/tcp.rs
Outdated
socket.set_reuse_address(true)?; | ||
socket.set_nonblocking(true)?; | ||
socket.bind(&addr.into())?; | ||
socket.listen(1)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The listen backlog of 1 may be too low for production use; consider increasing the backlog value or making it configurable to better handle incoming connections.
socket.listen(1)?; | |
socket.listen(128)?; |
Copilot uses AI. Check for mistakes.
c4aaf7c
to
1aaa426
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements exclusive IPv6 binding by setting the IPV6_V6ONLY flag for both TCP and UDP sockets to prevent dualstack binding. The changes include introducing helper functions to create sockets, removing unused instrumentation imports, and updating the Cargo.toml to add the socket2 dependency.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
taxy/src/server/udp.rs | Refactored UDP socket creation to use socket2 and apply IPV6_V6ONLY. |
taxy/src/server/tcp.rs | Refactored TCP listener creation similarly to include IPV6_V6ONLY flag. |
taxy/Cargo.toml | Updated dependencies by adding socket2 for low-level socket configuration. |
Comments suppressed due to low confidence (1)
taxy/src/server/tcp.rs:164
- [nitpick] Consider replacing the magic number '128' used for the backlog in the TCP listener with a named constant to improve code readability and maintainability.
socket.listen(128)?;
1aaa426
to
e2232d3
Compare
e2232d3
to
c88a5b2
Compare
c88a5b2
to
a5645c2
Compare
Implement the
IPV6_V6ONLY
flag to ensure that TCP and UDP sockets bind exclusively to IPv6 addresses, preventing dual-stack binding.