Split on first @ instead of the last to get the domain (thx Sam)

check-errors
Martin Dosch 3 years ago
parent 9044bbb998
commit 23cf25caa6

@ -39,7 +39,7 @@ func connect(options xmpp.Options, directTLS bool) (*xmpp.Client, error) {
// Look up SRV records if server is not specified manually.
srvMixed := srvMixed{}
if options.Host == "" {
server := options.User[strings.LastIndex(options.User, "@")+1:]
server := options.User[strings.Index(options.User, "@")+1:]
// Look up xmpp-client SRV records.
if _, addrs, err := net.LookupSRV("xmpp-client", "tcp", server); err == nil {
if len(addrs) > 0 {

@ -308,14 +308,14 @@ func main() {
// Use ALPN
var tlsConfig tls.Config
tlsConfig.ServerName = user[strings.LastIndex(user, "@")+1:]
tlsConfig.ServerName = user[strings.Index(user, "@")+1:]
tlsConfig.NextProtos = append(tlsConfig.NextProtos, "xmpp-client")
tlsConfig.InsecureSkipVerify = *flagSkipVerify
// Set XMPP connection options.
options := xmpp.Options{
Host: server,
User: user,
Host: server,
User: user,
// TODO: Check whether the timeout is reasonable or maybe make
// it configurable
DialTimeout: 1 * time.Second,

Loading…
Cancel
Save