From e38acf3e92f3b27871894012a3de60d7a6449c9a Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Sun, 25 Feb 2024 18:34:11 +0100 Subject: [PATCH] Improve behavior when no SRV records are set. --- connect.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connect.go b/connect.go index cf34b65..8b967f2 100644 --- a/connect.go +++ b/connect.go @@ -16,9 +16,9 @@ import ( func connect(options xmpp.Options, directTLS bool) (*xmpp.Client, error) { proxy := os.Getenv("HTTP_PROXY") + server := options.User[strings.Index(options.User, "@")+1:] // Look up SRV records if server is not specified manually. if options.Host == "" { - server := options.User[strings.Index(options.User, "@")+1:] // Don't do SRV look ups if proxy is set. if proxy == "" { // Look up xmpp-client SRV records. @@ -46,6 +46,9 @@ func connect(options xmpp.Options, directTLS bool) (*xmpp.Client, error) { } _, port, _ := net.SplitHostPort(options.Host) if port == "" { + if options.Host == "" { + options.Host = server + } // Try port 5223 if directTLS is set and no port is provided. if directTLS { options.NoTLS = false