Use net.JoinHostPort for adding the port to the host (thx Sam)

check-errors
Martin Dosch 3 years ago
parent 6df64d2446
commit 4ac87d88e1

@ -69,7 +69,7 @@ func connect(options xmpp.Options, directTLS bool) (*xmpp.Client, error) {
// Use StartTLS
options.NoTLS = true
options.StartTLS = true
options.Host = fmt.Sprintf("%s:%d", adr.host, adr.port)
options.Host = net.JoinHostPort(adr.host, fmt.Sprint(adr.port))
// Connect to server
client, err := options.NewClient()
if err == nil {
@ -79,7 +79,7 @@ func connect(options xmpp.Options, directTLS bool) (*xmpp.Client, error) {
// Use direct TLS
options.NoTLS = false
options.StartTLS = false
options.Host = fmt.Sprintf("%s:%d", adr.host, adr.port)
options.Host = net.JoinHostPort(adr.host, fmt.Sprint(adr.port))
// Connect to server
client, err := options.NewClient()
if err == nil {
@ -92,7 +92,7 @@ func connect(options xmpp.Options, directTLS bool) (*xmpp.Client, error) {
// Try port 5222 if no xmpp-client SRV records are provided.
options.NoTLS = true
options.StartTLS = true
options.Host = fmt.Sprintf("%s:%d", server, 5222)
options.Host = net.JoinHostPort(server, "5222")
// Connect to server
client, err := options.NewClient()
return client, err

Loading…
Cancel
Save