From 0fd114068f2a065bdd566a7a02a45ef6109bc22b Mon Sep 17 00:00:00 2001 From: Falaleev Maxim Date: Mon, 15 Sep 2014 10:12:12 +0400 Subject: [PATCH] Add anonymous auth --- xmpp.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xmpp.go b/xmpp.go index 6515fcc..00d86b5 100644 --- a/xmpp.go +++ b/xmpp.go @@ -268,6 +268,19 @@ func (c *Client) init(o *Options) error { } mechanism := "" for _, m := range f.Mechanisms.Mechanism { + if m == "ANONYMOUS" { + mechanism = m + fmt.Fprintf(c.conn, "\n", nsSASL) + break + } + + a := strings.SplitN(o.User, "@", 2) + if len(a) != 2 { + return errors.New("xmpp: invalid username (want user@domain): " + o.User) + } + user := a[0] + domain := a[1] + if m == "PLAIN" { mechanism = m // Plain authentication: send base64-encoded \x00 user \x00 password.