Skip to content

Commit

Permalink
wgcfg: fix bug preventing IPv6 addresses from working
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
  • Loading branch information
bradfitz authored and crawshaw committed Mar 30, 2020
1 parent dbc768b commit 2391f24
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions wgcfg/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package wgcfg

import (
"errors"
"fmt"
"net"
"strings"
Expand Down Expand Up @@ -46,17 +45,16 @@ func (conf *Config) ToUAPI() (string, error) {
}
var ip net.IP
for _, iterip := range ips {
iterip = iterip.To4()
if iterip != nil {
ip = iterip
if ip4 := iterip.To4(); ip4 != nil {
ip = ip4
break
}
if ip == nil {
ip = iterip
}
}
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}
reps = append(reps, resolvedEndpoint.String())
Expand Down

0 comments on commit 2391f24

Please sign in to comment.