mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
Don't naively join host and port using colon (fixes #2316)
This commit is contained in:
parent
47c7351b16
commit
fa75f54a05
@ -218,7 +218,7 @@ func (c *localClient) registerDevice(src net.Addr, device Device) bool {
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
u.Host = fmt.Sprintf("%s:%d", host, tcpAddr.Port)
|
||||
u.Host = net.JoinHostPort(host, strconv.Itoa(tcpAddr.Port))
|
||||
validAddresses = append(validAddresses, u.String())
|
||||
} else {
|
||||
validAddresses = append(validAddresses, addr.URL)
|
||||
@ -247,9 +247,9 @@ func addrToAddr(addr *net.TCPAddr) string {
|
||||
if len(addr.IP) == 0 || addr.IP.IsUnspecified() {
|
||||
return fmt.Sprintf(":%c", addr.Port)
|
||||
} else if bs := addr.IP.To4(); bs != nil {
|
||||
return fmt.Sprintf("%s:%c", bs.String(), addr.Port)
|
||||
return net.JoinHostPort(bs.String(), strconv.Itoa(addr.Port))
|
||||
} else if bs := addr.IP.To16(); bs != nil {
|
||||
return fmt.Sprintf("[%s]:%c", bs.String(), addr.Port)
|
||||
return net.JoinHostPort(bs.String(), strconv.Itoa(addr.Port))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user