Fix ExternalAddress parsing problem under IPv6

`!strings.Contains(host, ":")` will fail miserably under ipv6
pull/6/head
Davanum Srinivas 2018-01-04 14:00:04 -05:00
parent 0b0254f03e
commit c258d4df84
1 changed files with 4 additions and 4 deletions

View File

@ -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