Compare commits
4 Commits
5cfc61169b
...
6465ebd169
| Author | SHA1 | Date |
|---|---|---|
|
|
6465ebd169 | |
|
|
2d4531739a | |
|
|
b32173d11e | |
|
|
3125d02cf6 |
|
|
@ -3,6 +3,7 @@ package xmpp
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -27,18 +28,8 @@ func HomeServerAddrs(jid JID) (addr []string, err error) {
|
||||||
|
|
||||||
// Build list of "host:port" strings.
|
// Build list of "host:port" strings.
|
||||||
for _, a := range addrs {
|
for _, a := range addrs {
|
||||||
target := parseTargetDomainName(a.Target)
|
target := strings.TrimRight(a.Target, ".")
|
||||||
addr = append(addr, fmt.Sprintf("%s:%d", target, a.Port))
|
addr = append(addr, fmt.Sprintf("%s:%d", target, a.Port))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the last dot in the domain name if exist
|
|
||||||
func parseTargetDomainName(domainName string) (ret string) {
|
|
||||||
if domainName[len(domainName)-1] == '.' {
|
|
||||||
ret = parseTargetDomainName(domainName[:len(domainName)-1])
|
|
||||||
} else {
|
|
||||||
ret = domainName
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NSPing = "urn:xmpp:ping"
|
NSPing = "urn:xmpp:ping"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Ping struct {
|
type Ping struct {
|
||||||
XMLName xml.Name `xml:"urn:xmpp:ping ping"`
|
XMLName xml.Name `xml:"urn:xmpp:ping ping"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ import (
|
||||||
const (
|
const (
|
||||||
NSRemoteRosterManager = "urn:xmpp:tmp:roster-management:0"
|
NSRemoteRosterManager = "urn:xmpp:tmp:roster-management:0"
|
||||||
|
|
||||||
RemoteRosterManagerTypeRequest = "request"
|
RemoteRosterManagerTypeRequest = "request"
|
||||||
RemoteRosterManagerTypeAllowed = "allowed"
|
RemoteRosterManagerTypeAllowed = "allowed"
|
||||||
RemoteRosterManagerTypeRejected = "rejected"
|
RemoteRosterManagerTypeRejected = "rejected"
|
||||||
)
|
)
|
||||||
|
|
||||||
// XEP-0321: Remote Roster Manager
|
// XEP-0321: Remote Roster Manager
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NSRoster = "jabber:iq:roster"
|
NSRoster = "jabber:iq:roster"
|
||||||
|
|
||||||
RosterSubscriptionBoth = "both"
|
RosterSubscriptionBoth = "both"
|
||||||
RosterSubscriptionFrom = "from"
|
RosterSubscriptionFrom = "from"
|
||||||
|
|
@ -14,13 +14,13 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type RosterQuery struct {
|
type RosterQuery struct {
|
||||||
XMLName xml.Name `xml:"jabber:iq:roster query"`
|
XMLName xml.Name `xml:"jabber:iq:roster query"`
|
||||||
Items []RosterItem `xml:"item"`
|
Items []RosterItem `xml:"item"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RosterItem struct {
|
type RosterItem struct {
|
||||||
JID string `xml:"jid,attr"`
|
JID string `xml:"jid,attr"`
|
||||||
Name string `xml:"name,attr,omitempty"`
|
Name string `xml:"name,attr,omitempty"`
|
||||||
Subscription string `xml:"subscription,attr"`
|
Subscription string `xml:"subscription,attr"`
|
||||||
Groupes []string `xml:"group"`
|
Groupes []string `xml:"group"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ type Message struct {
|
||||||
Error *Error `xml:"error"`
|
Error *Error `xml:"error"`
|
||||||
Lang string `xml:"xml:lang,attr,omitempty"`
|
Lang string `xml:"xml:lang,attr,omitempty"`
|
||||||
|
|
||||||
Confir *Confirm `xml:"confirm"` // XEP-0070
|
Confirm *Confirm `xml:"confirm"` // XEP-0070
|
||||||
|
|
||||||
Active *Active `xml:"active"` // XEP-0085
|
Active *Active `xml:"active"` // XEP-0085
|
||||||
Composing *Composing `xml:"composing"` // XEP-0085
|
Composing *Composing `xml:"composing"` // XEP-0085
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ type StreamConfig struct {
|
||||||
// causes incoming stanzas to be XML-parsed a second time.
|
// causes incoming stanzas to be XML-parsed a second time.
|
||||||
LogStanzas bool
|
LogStanzas bool
|
||||||
|
|
||||||
// The dommain connection for certificat validation.
|
// The dommain connection for certificate validation.
|
||||||
ConnectionDomain string
|
ConnectionDomain string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue