Skip to content

Commit

Permalink
Fix ExternalAddress parsing problem under IPv6
Browse files Browse the repository at this point in the history
`!strings.Contains(host, ":")` will fail miserably under ipv6

Kubernetes-commit: c258d4df84089b08b9cbd37b1dee4b00576a2532
  • Loading branch information
dims authored and k8s-publishing-bot committed Jan 4, 2018
1 parent 1f8819c commit 9dd28d8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ func (c *Config) Complete(informers informers.SharedInformerFactory) CompletedCo
if host == "" && c.PublicAddress != nil {
host = c.PublicAddress.String()
}
if !strings.Contains(host, ":") {
if c.ReadWritePort != 0 {
host = net.JoinHostPort(host, strconv.Itoa(c.ReadWritePort))
}

// if there is no port, and we have a ReadWritePort, use that
if _, _, err := net.SplitHostPort(host); err != nil && c.ReadWritePort != 0 {
host = net.JoinHostPort(host, strconv.Itoa(c.ReadWritePort))
}
c.ExternalAddress = host

Expand Down

0 comments on commit 9dd28d8

Please sign in to comment.