summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-05-22 21:04:04 +0200
committerxengineering <me@xengineering.eu>2023-05-22 21:07:25 +0200
commit4fa114cd1efcba90054247f30fad957c8f0ec06d (patch)
treecdd2c785be031c257e36c50e7956d5359bba1557
parent76604ce0a11a6228cb12c46cb608c565bf1d47ec (diff)
downloadlimox-4fa114cd1efcba90054247f30fad957c8f0ec06d.tar
limox-4fa114cd1efcba90054247f30fad957c8f0ec06d.tar.zst
limox-4fa114cd1efcba90054247f30fad957c8f0ec06d.zip
Move stream logic to new xmpp/stream.go
-rw-r--r--xmpp/stream.go33
-rw-r--r--xmpp/xmpp.go28
2 files changed, 33 insertions, 28 deletions
diff --git a/xmpp/stream.go b/xmpp/stream.go
new file mode 100644
index 0000000..803071a
--- /dev/null
+++ b/xmpp/stream.go
@@ -0,0 +1,33 @@
+package xmpp
+
+import (
+ "encoding/xml"
+ "log"
+)
+
+func sendStreamStart(enc *encoder, jid string) xml.EndElement {
+ start := xml.StartElement{
+ xml.Name{"jabber:client", "stream:stream"},
+ []xml.Attr{
+ xml.Attr{xml.Name{"", "from"}, jid},
+ xml.Attr{xml.Name{"", "to"}, domainpart(jid)},
+ xml.Attr{xml.Name{"", "version"}, "1.0"},
+ xml.Attr{xml.Name{"", "xml:lang"}, "en"},
+ xml.Attr{xml.Name{"", "xmlns:stream"}, "http://etherx.jabber.org/streams"},
+ },
+ }
+
+ err := enc.encodeNow(start)
+ if err != nil {
+ log.Println("Could not encode stream start!")
+ }
+
+ return start.End()
+}
+
+func sendStreamEnd(enc *encoder, end xml.EndElement) {
+ err := enc.encodeNow(end)
+ if err != nil {
+ log.Println("Could not encode stream end!")
+ }
+}
diff --git a/xmpp/xmpp.go b/xmpp/xmpp.go
index 07d4c6d..f017889 100644
--- a/xmpp/xmpp.go
+++ b/xmpp/xmpp.go
@@ -3,7 +3,6 @@ package xmpp
import (
"crypto/tls"
"crypto/x509"
- "encoding/xml"
"log"
)
@@ -95,30 +94,3 @@ func (c *Conn) Run() {
}
}
}
-
-func sendStreamStart(enc *encoder, jid string) xml.EndElement {
- start := xml.StartElement{
- xml.Name{"jabber:client", "stream:stream"},
- []xml.Attr{
- xml.Attr{xml.Name{"", "from"}, jid},
- xml.Attr{xml.Name{"", "to"}, domainpart(jid)},
- xml.Attr{xml.Name{"", "version"}, "1.0"},
- xml.Attr{xml.Name{"", "xml:lang"}, "en"},
- xml.Attr{xml.Name{"", "xmlns:stream"}, "http://etherx.jabber.org/streams"},
- },
- }
-
- err := enc.encodeNow(start)
- if err != nil {
- log.Println("Could not encode stream start!")
- }
-
- return start.End()
-}
-
-func sendStreamEnd(enc *encoder, end xml.EndElement) {
- err := enc.encodeNow(end)
- if err != nil {
- log.Println("Could not encode stream end!")
- }
-}