mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-09-18 20:57:50 +02:00
wgcfg: fix bug preventing IPv6 addresses from working
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
30908fdc5d
commit
024d6ea4c2
@ -6,7 +6,6 @@
|
|||||||
package wgcfg
|
package wgcfg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
@ -46,9 +45,8 @@ func (conf *Config) ToUAPI() (string, error) {
|
|||||||
}
|
}
|
||||||
var ip net.IP
|
var ip net.IP
|
||||||
for _, iterip := range ips {
|
for _, iterip := range ips {
|
||||||
iterip = iterip.To4()
|
if ip4 := iterip.To4(); ip4 != nil {
|
||||||
if iterip != nil {
|
ip = ip4
|
||||||
ip = iterip
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
@ -56,7 +54,7 @@ func (conf *Config) ToUAPI() (string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
return "", errors.New("Unable to resolve IP address of endpoint")
|
return "", fmt.Errorf("unable to resolve IP address of endpoint %q (%v)", ep.Host, ips)
|
||||||
}
|
}
|
||||||
resolvedEndpoint := Endpoint{ip.String(), ep.Port}
|
resolvedEndpoint := Endpoint{ip.String(), ep.Port}
|
||||||
reps = append(reps, resolvedEndpoint.String())
|
reps = append(reps, resolvedEndpoint.String())
|
||||||
|
Loading…
Reference in New Issue
Block a user