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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ecca0a63ed
commit
a564286402
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user