mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 10:28:49 -07:00
lib/config: Use net.JoinHostPort instead of string manipulation (#8470)
This commit is contained in:
parent
585fb3f49b
commit
5977868165
@ -590,7 +590,7 @@ func filterURLSchemePrefix(addrs []string, prefix string) []string {
|
||||
// a random high port is returned.
|
||||
func getFreePort(host string, ports ...int) (int, error) {
|
||||
for _, port := range ports {
|
||||
c, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, port))
|
||||
c, err := net.Listen("tcp", net.JoinHostPort(host, strconv.Itoa(port)))
|
||||
if err == nil {
|
||||
c.Close()
|
||||
return port, nil
|
||||
|
Loading…
Reference in New Issue
Block a user