Skip to content

Support dual-stack UDP wildcard listeners - #200

Open
Mygod wants to merge 3 commits into
masterking32:mainfrom
Mygod:agent/dual-stack-udp
Open

Support dual-stack UDP wildcard listeners#200
Mygod wants to merge 3 commits into
masterking32:mainfrom
Mygod:agent/dual-stack-udp

Conversation

@Mygod

@Mygod Mygod commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • Use an empty UDP_HOST as Go's family-neutral UDP wildcard.
  • Accept IPv4 and IPv6 through one socket where IPv4-mapped IPv6 is supported, while allowing Go to select an available family otherwise.
  • Preserve explicit unbracketed IP literals as configured.
  • Reject non-IP and bracketed UDP_HOST values instead of silently binding a wildcard address.
  • Format IPv6 listener addresses correctly with net.JoinHostPort.
  • Document wildcard behavior across all README translations and the sample configuration.
  • Add Linux integration coverage for default IPv4/IPv6 traffic and explicit IPv6 wildcard handling.

Compatibility

The empty default maps to UDPAddr.IP == nil, which is Go's family-neutral wildcard. On platforms supporting IPv4-mapped IPv6, it accepts IPv4 and IPv6 traffic through one socket. Otherwise Go selects an available address family.

Non-empty UDP_HOST values must be unbracketed IP literals. Invalid values, hostnames, and bracketed IPv6 values fail configuration validation instead of expanding the listener to all interfaces.

The integration test probes actual mapped-IPv6 capability before requiring both address families.

Validation

  • go test ./...
  • go vet ./...
  • go test -race ./internal/config ./internal/udpserver -run 'Test(ServerConfigAddress|ServerConfigUDPHostValidation|LoadServerConfigFromJSONBase64AppliesDefaults|OpenUDPListenersRejectsInvalidUDPHost|DefaultUDPListenerIsDualStack|ExplicitIPv6WildcardUsesIPv6Socket)$' -count=20

@Mygod
Mygod marked this pull request as ready for review July 22, 2026 18:38
@masterking32
masterking32 requested a review from Copilot July 23, 2026 04:39

Copilot AI left a comment

Copy link
Copy Markdown

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 updates the server’s UDP bind behavior and documentation to better support dual-stack wildcard listeners (IPv4+IPv6) where the OS supports IPv4-mapped IPv6, while preserving explicit IPv6 wildcard behavior and improving IPv6 address formatting.

Changes:

  • Treat UDP_HOST = "0.0.0.0" as a generic wildcard (by letting Go choose the wildcard socket) to enable dual-stack where supported.
  • Format listener addresses correctly for IPv6 using net.JoinHostPort, and add unit coverage for the address formatter.
  • Add Linux integration tests and update all README translations + sample config to document wildcard behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
server_config.toml.simple Documents dual-stack wildcard vs explicit IPv6 wildcard behavior for UDP_HOST.
README.MD Updates UDP_HOST documentation to describe dual-stack behavior and explicit IPv6 wildcard usage.
README_ZH.MD Same documentation update (Chinese translation).
README_RU.MD Same documentation update (Russian translation).
README_IT.MD Same documentation update (Italian translation).
README_FA.MD Same documentation update (Persian translation).
README_ES.MD Same documentation update (Spanish translation).
internal/udpserver/server_runtime.go Adjusts wildcard handling so 0.0.0.0 can become a generic wildcard bind.
internal/udpserver/server_runtime_linux_test.go Adds Linux-only integration coverage for dual-stack wildcard and explicit IPv6 wildcard preservation.
internal/config/server.go Uses net.JoinHostPort for correct IPv6 address formatting.
internal/config/server_test.go Adds unit tests for ServerConfig.Address() IPv4/IPv6 formatting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/udpserver/server_runtime.go Outdated
Comment on lines +31 to +35
ip := net.ParseIP(s.cfg.UDPHost)
if ip != nil && ip.IsUnspecified() && ip.To4() != nil {
// Let Go select a dual-stack wildcard socket where the platform supports it.
ip = nil
}
Comment thread internal/config/server.go
Comment on lines 475 to +476
func (c ServerConfig) Address() string {
return fmt.Sprintf("%s:%d", c.UDPHost, c.UDPPort)
return net.JoinHostPort(c.UDPHost, strconv.Itoa(c.UDPPort))

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

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