summaryrefslogtreecommitdiff
path: root/xmpp/routing.go
diff options
context:
space:
mode:
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")
+}