diff options
Diffstat (limited to 'xmpp/streams.go')
-rw-r--r-- | xmpp/streams.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/xmpp/streams.go b/xmpp/streams.go index 3aca8a2..8f6fd03 100644 --- a/xmpp/streams.go +++ b/xmpp/streams.go @@ -5,6 +5,23 @@ import ( "log" ) +type streamFeatures struct { + SaslMechanisms []string `xml:"mechanisms>mechanism"` +} + +func handleStreamFeatures(s *session, f streamFeatures) { + if len(f.SaslMechanisms) > 0 { + for _, v := range f.SaslMechanisms { + if v == "PLAIN" { + s.sasl() + return + } + } + log.Println("No compatible SASL mechanism found!") + return + } +} + func openStream(e *xml.Encoder, jid string) { start := xml.StartElement{ xml.Name{"jabber:client", "stream:stream"}, @@ -63,7 +80,3 @@ func iqHandler(s *session, e []xml.Token) { } } } - -type streamFeatures struct { - SaslMechanisms []string `xml:"mechanisms>mechanism"` -} |