mirror of
https://salsa.debian.org/mdosch/go-sendxmpp
synced 2024-11-12 13:10:25 +00:00
Fix issue with SRV lookup for xmpps-client.
This commit is contained in:
parent
6c3fe6246a
commit
e4e33cdf75
@ -288,28 +288,28 @@ func main() {
|
||||
server = *flagServer
|
||||
}
|
||||
|
||||
// Lookup SRV record for xmpps-client if direct TLS is requested and the server is not
|
||||
// specified.
|
||||
if *flagTLS {
|
||||
if _, addrs, err := net.LookupSRV("xmpps-client", "tcp", server); err == nil {
|
||||
// Determine server part if no server is specified.
|
||||
if server == "" {
|
||||
server = strings.Split(user, "@")[1]
|
||||
|
||||
if len(addrs) > 0 {
|
||||
// Default to first record
|
||||
server = fmt.Sprintf("%s:%d", addrs[0].Target, addrs[0].Port)
|
||||
defP := addrs[0].Priority
|
||||
for _, adr := range addrs {
|
||||
if adr.Priority < defP {
|
||||
server = fmt.Sprintf("%s:%d", adr.Target, adr.Port)
|
||||
defP = adr.Priority
|
||||
// Lookup SRV record for xmpps-client if direct TLS is requested
|
||||
if *flagTLS {
|
||||
if _, addrs, err := net.LookupSRV("xmpps-client", "tcp", server); err == nil {
|
||||
|
||||
if len(addrs) > 0 {
|
||||
// Default to first record
|
||||
server = fmt.Sprintf("%s:%d", addrs[0].Target, addrs[0].Port)
|
||||
defP := addrs[0].Priority
|
||||
for _, adr := range addrs {
|
||||
if adr.Priority < defP {
|
||||
server = fmt.Sprintf("%s:%d", adr.Target, adr.Port)
|
||||
defP = adr.Priority
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use the JIDs server part if no server is specified.
|
||||
if server == "" {
|
||||
server = strings.Split(user, "@")[1]
|
||||
}
|
||||
|
||||
// Overwrite password if specified via command line flag.
|
||||
|
Loading…
Reference in New Issue
Block a user