summaryrefslogtreecommitdiff
path: root/xmpp/routing.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-05-21 13:00:58 +0200
committerxengineering <me@xengineering.eu>2023-05-21 13:00:58 +0200
commit37753409dc55da1a1cc3feed139f287a2d6215bb (patch)
tree63afb3226cae02f465d998f53f069021e407810a /xmpp/routing.go
parentfd435f313610595114b86831354fa310394a840e (diff)
downloadlimox-37753409dc55da1a1cc3feed139f287a2d6215bb.tar
limox-37753409dc55da1a1cc3feed139f287a2d6215bb.tar.zst
limox-37753409dc55da1a1cc3feed139f287a2d6215bb.zip
Implement SASL method parsing
Diffstat (limited to 'xmpp/routing.go')
-rw-r--r--xmpp/routing.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/xmpp/routing.go b/xmpp/routing.go
index 34136f4..55ec135 100644
--- a/xmpp/routing.go
+++ b/xmpp/routing.go
@@ -95,7 +95,35 @@ type elementRoutingTable []struct {
}
func streamFeatures(b []xml.Token) error {
- log.Println("Received stream features")
+ err := sendSaslAuth(b)
+ if err != nil {
+ return err
+ }
return nil
}
+
+func sendSaslAuth(b []xml.Token) error {
+ mechanisms := make([]string, 0)
+ for i, v := range(b) {
+ switch token := v.(type) {
+ case xml.StartElement:
+ expected := xml.Name{"urn:ietf:params:xml:ns:xmpp-sasl", "mechanism"}
+ if token.Name == expected {
+ if i >= (len(b)-1) { continue }
+ switch payload := b[i+1].(type) {
+ case xml.CharData:
+ mechanisms = append(mechanisms, string(payload))
+ }
+ }
+ }
+ }
+
+ for _, v := range(mechanisms) {
+ if v == "PLAIN" {
+ return nil
+ }
+ }
+
+ return errors.New("No compatible SASL mechanism given")
+}