Permalink
Browse files

IPv6: Resolving hostname to IP address

Add square brackets to IPv6 addresses that are resolved.
  • Loading branch information...
pmichali committed Mar 5, 2018
1 parent a5451cd commit 0502713a3083bbe4bc5c322231872d20f1566b22
Showing with 6 additions and 1 deletion.
  1. +6 −1 pilot/pkg/proxy/resolve.go
@@ -41,7 +41,12 @@ func ResolveAddr(addr string) (string, error) {
if lookupErr != nil {
return "", fmt.Errorf("lookup failed for udp address: %v", lookupErr)
}
resolvedAddr := fmt.Sprintf("%s%s", addrs[0].IP, port)
var resolvedAddr string
if addrs[0].IP.To4() == nil {
resolvedAddr = fmt.Sprintf("[%s]%s", addrs[0].IP, port)
} else {
resolvedAddr = fmt.Sprintf("%s%s", addrs[0].IP, port)
}
log.Infof("Addr resolved to: %s", resolvedAddr)
return resolvedAddr, nil
}

0 comments on commit 0502713

Please sign in to comment.