-
-
Notifications
You must be signed in to change notification settings - Fork 798
[client] Handle IPv6 candidates in userspace bind #4123
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
base: main
Are you sure you want to change the base?
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 enhances IPv6 support in the client’s userspace bind by introducing dual-stack packet connections and updating address formatting.
- Extend
LocalAddr
to return appropriate IPv4/IPv6 unspecified addresses. - Introduce
DualStackPacketConn
and integrate it into UDPMux and ICEBind. - Add
formatEndpoint
to bracket IPv6 addresses and update ICE candidate logging.
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
sharedsock/sock_linux.go | Updated LocalAddr to select IPv4/IPv6/dual-stack addresses |
go.mod | Bumped WireGuard-Go replacement version |
client/internal/peer/worker_ice.go | Added formatEndpoint for proper IPv6 bracket formatting |
client/iface/bind/udp_mux_universal.go | Detect and dispatch to DualStackPacketConn in three paths |
client/iface/bind/udp_mux.go | Added dual-stack dispatch in writeTo |
client/iface/bind/ice_bind.go | Refactored receiver creation, multiplex logic for IPv4/IPv6 |
client/iface/bind/dual_stack_conn.go | New DualStackPacketConn type supporting IPv4 & IPv6 |
Comments suppressed due to low confidence (1)
client/iface/bind/ice_bind.go:256
- The added parameter
isIPv6
is never used infilterOutStunMessages
, which will cause a compilation error for an unused variable. Either remove this parameter or incorporateisIPv6
into the filtering logic.
func (s *ICEBind) filterOutStunMessages(buffers [][]byte, n int, addr net.Addr, isIPv6 bool) (bool, error) {
func (u *udpConn) WriteTo(b []byte, addr net.Addr) (int, error) { | ||
// Check if this is a dual-stack connection and handle IPv6 addresses properly | ||
if dualStackConn, ok := u.PacketConn.(*DualStackPacketConn); ok { | ||
return dualStackConn.WriteTo(b, addr) | ||
} | ||
|
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.
[nitpick] The dual-stack type assertion and WriteTo
logic is duplicated in WriteTo
, handleCachedAddress
, and handleUncachedAddress
. Consider extracting a helper to reduce duplication.
func (u *udpConn) WriteTo(b []byte, addr net.Addr) (int, error) { | |
// Check if this is a dual-stack connection and handle IPv6 addresses properly | |
if dualStackConn, ok := u.PacketConn.(*DualStackPacketConn); ok { | |
return dualStackConn.WriteTo(b, addr) | |
} | |
func (u *udpConn) writeToDualStack(b []byte, addr net.Addr) (int, error) { | |
if dualStackConn, ok := u.PacketConn.(*DualStackPacketConn); ok { | |
return dualStackConn.WriteTo(b, addr) | |
} | |
return 0, nil | |
} | |
func (u *udpConn) WriteTo(b []byte, addr net.Addr) (int, error) { | |
// Use helper to handle dual-stack connections | |
if n, err := u.writeToDualStack(b, addr); err != nil || n > 0 { | |
return n, err | |
} |
Copilot uses AI. Check for mistakes.
|
|
||
// ReadFrom reads from both IPv4 and IPv6 connections | ||
func (d *DualStackPacketConn) ReadFrom(b []byte) (n int, addr net.Addr, err error) { | ||
// Prefer IPv4 if available |
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.
Shouldn't we read from both?
Describe your changes
Issue ticket number and link
Stack
Checklist