Compare commits
2 Commits
3f618b50f5
...
30ec9e14fb
| Author | SHA1 | Date |
|---|---|---|
|
|
30ec9e14fb | |
|
|
d90f7642e3 |
|
|
@ -115,7 +115,7 @@ func startTLS(stream *Stream, config *ClientConfig) error {
|
|||
return err
|
||||
}
|
||||
|
||||
tlsConfig := tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}
|
||||
tlsConfig := tls.Config{InsecureSkipVerify: config.InsecureSkipVerify, ServerName: stream.connDomain}
|
||||
return stream.UpgradeTLS(&tlsConfig)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,18 @@ func HomeServerAddrs(jid JID) (addr []string, err error) {
|
|||
|
||||
// Build list of "host:port" strings.
|
||||
for _, a := range addrs {
|
||||
addr = append(addr, fmt.Sprintf("%s:%d", a.Target, a.Port))
|
||||
target := parseTargetDomainName(a.Target)
|
||||
addr = append(addr, fmt.Sprintf("%s:%d", target, a.Port))
|
||||
}
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,4 +172,5 @@ var (
|
|||
FeatureNotImplemented = ErrorCondition{nsErrorStanzas, "feature-not-implemented"}
|
||||
RemoteServerNotFound = ErrorCondition{nsErrorStanzas, "remote-server-not-found"}
|
||||
ServiceUnavailable = ErrorCondition{nsErrorStanzas, "service-unavailable"}
|
||||
NotAuthorized = ErrorCondition{nsErrorStanzas, "not-authorized"}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Stream configuration.
|
||||
|
|
@ -24,6 +25,7 @@ type Stream struct {
|
|||
config *StreamConfig
|
||||
stanzaBuf string
|
||||
incomingNamespace nsMap
|
||||
connDomain string
|
||||
}
|
||||
|
||||
// Create a XML stream connection. A Steam is used by an XMPP instance to
|
||||
|
|
@ -41,7 +43,7 @@ func NewStream(addr string, config *StreamConfig) (*Stream, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
stream := &Stream{conn: conn, dec: xml.NewDecoder(conn), config: config}
|
||||
stream := &Stream{conn: conn, dec: xml.NewDecoder(conn), config: config, connDomain: strings.SplitN(addr, ":", 2)[0]}
|
||||
|
||||
if err := stream.send([]byte("<?xml version='1.0' encoding='utf-8'?>")); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Reference in New Issue