Support IPv6 server addresses without ports

This commit is contained in:
Brandon McGinty (chatgpt)
2026-08-09 23:55:51 -04:00
committed by Brandon McGinty
parent 770635955a
commit d7dcaa8b21
2 changed files with 24 additions and 3 deletions
+10 -3
View File
@@ -9,6 +9,7 @@ import (
"fmt"
"io"
"log"
"net"
"net/http"
"os"
"os/exec"
@@ -226,9 +227,7 @@ func main() {
os.Exit(0)
}
if !strings.Contains(*server, ":") {
*server = (*server + ":64738")
}
*server = serverAddress(*server)
// Initialize
b := Barnard{
@@ -282,6 +281,14 @@ func main() {
handle_error(&b)
}
// serverAddress adds Mumble's default port without corrupting an IPv6 literal.
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)