From 2b932f4cd790eb4a66745a3d9718867c2742ae99 Mon Sep 17 00:00:00 2001 From: Markus Witt Date: Mon, 1 Jun 2020 23:57:02 +0200 Subject: [PATCH] try looking up a SRV record first --- gumbleutil/main.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/gumbleutil/main.go b/gumbleutil/main.go index 36419ea..f52dbb0 100644 --- a/gumbleutil/main.go +++ b/gumbleutil/main.go @@ -31,10 +31,24 @@ func Main(listeners ...gumble.EventListener) { flag.Parse() } - host, port, err := net.SplitHostPort(*server) - if err != nil { - host = *server - port = strconv.Itoa(gumble.DefaultPort) + var host string + var port string + + // try to lookup SRV records first + _, records, err := net.LookupSRV("mumble", "tcp", *server) + if err == nil { + // just use the first one, which probably isn't a good idea + for _, srv := range records { + host = srv.Target + port = strconv.Itoa(int(srv.Port)) + break + } + } else { + host, port, err = net.SplitHostPort(*server) + if err != nil { + host = *server + port = strconv.Itoa(gumble.DefaultPort) + } } keepAlive := make(chan bool)