summaryrefslogtreecommitdiff
path: root/xmpp.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-05-11 19:56:16 +0200
committerxengineering <me@xengineering.eu>2023-05-11 19:56:16 +0200
commit8569dfec15368986773e67d8c1598c0e02b39084 (patch)
tree81b79e55a4d0aea5489608bc0a95416d57dc2a40 /xmpp.go
parent6ec791ba0fffb2a0c8e0e603f4f5f0cc2b6f5e18 (diff)
downloadlimox-8569dfec15368986773e67d8c1598c0e02b39084.tar
limox-8569dfec15368986773e67d8c1598c0e02b39084.tar.zst
limox-8569dfec15368986773e67d8c1598c0e02b39084.zip
Refactor with new setupConn()
Diffstat (limited to 'xmpp.go')
-rw-r--r--xmpp.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/xmpp.go b/xmpp.go
index 9e09700..d7c8790 100644
--- a/xmpp.go
+++ b/xmpp.go
@@ -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)