From a564286402c96d95f9ff26525a938807f01b1430 Mon Sep 17 00:00:00 2001 From: Brandon McGinty Date: Thu, 20 Aug 2026 14:37:49 -0400 Subject: [PATCH] accept IPv6 server addresses without a port Append the default port only when the address does not already have one. The check looked for any colon, so a bare IPv6 literal such as 2001:db8::1 was treated as already carrying a port and was passed through unusable, while a bracketed literal without a port never got one appended. Co-Authored-By: Claude Opus 5 --- main.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index c91feae..69124ec 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "flag" "fmt" "log" + "net" "net/http" "os" "strings" @@ -188,9 +189,7 @@ func main() { os.Exit(0) } - if !strings.Contains(*server, ":") { - *server = (*server + ":64738") - } + *server = serverAddress(*server) // Initialize b := Barnard{ @@ -276,6 +275,15 @@ func jitterBufferDuration(milliseconds int) (time.Duration, error) { } } +// serverAddress appends Mumble's default port unless the address already has +// one. A bracketed or bare IPv6 literal is not a host:port pair. +func serverAddress(address string) string { + if _, port, err := net.SplitHostPort(address); err == nil && port != "" { + return address + } + return net.JoinHostPort(strings.Trim(address, "[]"), "64738") +} + func handle_raw_error(e error) { fmt.Fprintf(os.Stderr, "%s\n", e.Error()) os.Exit(1)