forked from jshiffer/go-xmpp
Fix host with anonymous connection (#129)
This commit is contained in:
parent
b40e129499
commit
db1339b3a5
10
xmpp.go
10
xmpp.go
@ -339,13 +339,19 @@ func (c *Client) init(o *Options) error {
|
|||||||
var domain string
|
var domain string
|
||||||
var user string
|
var user string
|
||||||
a := strings.SplitN(o.User, "@", 2)
|
a := strings.SplitN(o.User, "@", 2)
|
||||||
if len(o.User) > 0 {
|
// Check if User is not empty. Otherwise, we'll be attempting ANONYMOUS with Host domain.
|
||||||
|
switch {
|
||||||
|
case len(o.User) > 0:
|
||||||
if len(a) != 2 {
|
if len(a) != 2 {
|
||||||
return errors.New("xmpp: invalid username (want user@domain): " + o.User)
|
return errors.New("xmpp: invalid username (want user@domain): " + o.User)
|
||||||
}
|
}
|
||||||
user = a[0]
|
user = a[0]
|
||||||
domain = a[1]
|
domain = a[1]
|
||||||
} // Otherwise, we'll be attempting ANONYMOUS
|
case strings.Contains(o.Host, ":"):
|
||||||
|
domain = strings.SplitN(o.Host, ":", 2)[0]
|
||||||
|
default:
|
||||||
|
domain = o.Host
|
||||||
|
}
|
||||||
|
|
||||||
// Declare intent to be a jabber client and gather stream features.
|
// Declare intent to be a jabber client and gather stream features.
|
||||||
f, err := c.startStream(o, domain)
|
f, err := c.startStream(o, domain)
|
||||||
|
Loading…
Reference in New Issue
Block a user