diff options
-rw-r--r-- | xmpp.go | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -16,18 +16,8 @@ const ( ) func (l *Limox) xmpp(jid string, pwd string) { - log.Printf("JID: '%s' PWD: '%s'\n", jid, pwd) - domain := domainpart(jid) - log.Printf("Domain: '%s'\n", domain) - - roots, err := x509.SystemCertPool() - if err != nil { - l.XmppEvents <- err - return - } - - conn, err := tls.Dial("tcp", domain+":"+"5223", &tls.Config{RootCAs: roots}) + conn, err := setupConn(jid) if err != nil { l.XmppEvents <- err return @@ -71,6 +61,17 @@ func (l *Limox) xmpp(jid string, pwd string) { l.XmppEvents <- XmppDisconnect } +func setupConn(jid string) (*tls.Conn, error) { + domain := domainpart(jid) + + roots, err := x509.SystemCertPool() + if err != nil { + return nil, err + } + + return tls.Dial("tcp", domain+":"+"5223", &tls.Config{RootCAs: roots}) +} + func rxRoutine(conn *tls.Conn, tokens chan xml.Token, terminator chan bool) { quit := false dec := xml.NewDecoder(conn) |