summaryrefslogtreecommitdiff
path: root/xmpp/streams.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-07-04 13:48:34 +0200
committerxengineering <me@xengineering.eu>2023-07-04 13:48:34 +0200
commit92534f5af88b42665ad44f2495fe5dfb116d3406 (patch)
tree53fe906edb6ce70f22e6602469b9ce4da5d55675 /xmpp/streams.go
parent45b04ef092a99d0d3f355e27896c82f1dbf15d28 (diff)
downloadlimox-92534f5af88b42665ad44f2495fe5dfb116d3406.tar
limox-92534f5af88b42665ad44f2495fe5dfb116d3406.tar.zst
limox-92534f5af88b42665ad44f2495fe5dfb116d3406.zip
First working version of new RX concept
This uses xml.Decoder.DecodeElement() which makes parsing way easier. This first step is just able to parse stream features partially.
Diffstat (limited to 'xmpp/streams.go')
-rw-r--r--xmpp/streams.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/xmpp/streams.go b/xmpp/streams.go
index b9c0cb7..9c90554 100644
--- a/xmpp/streams.go
+++ b/xmpp/streams.go
@@ -40,20 +40,6 @@ func closeStream(e *xml.Encoder) {
}
}
-func streamFeaturesHandler(s *session, e []xml.Token) {
- if hasSaslPlain(e) {
- s.sasl()
- return
- }
-
- if hasBind(e) {
- s.sendBind()
- return
- }
-
- log.Println("Stream has no implemented features!")
-}
-
func iqHandler(s *session, e []xml.Token) {
isResult := false
idMatches := false
@@ -77,3 +63,22 @@ func iqHandler(s *session, e []xml.Token) {
}
}
}
+
+type streamFeatures struct {
+ Mechanisms struct {
+ Items []struct {
+ Type string `xml:",innerxml"`
+ } `xml:"mechanism"`
+ } `xml:"mechanisms"`
+}
+
+func streamFeaturesHandler(s *xml.StartElement, d *xml.Decoder, c chan<- any) {
+ e := streamFeatures{}
+
+ err := d.DecodeElement(&e, s)
+ if err != nil {
+ log.Printf("Could not decode stream features: %v\n", err)
+ }
+
+ c <- e
+}