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