forked from jshiffer/go-xmpp
Merge pull request #31 from max107/anonymous
Add anonymous auth via empty User and Password
This commit is contained in:
commit
11887e6acb
13
xmpp.go
13
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, "<auth xmlns='%s' mechanism='ANONYMOUS' />\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.
|
||||
|
Loading…
Reference in New Issue
Block a user