Skip to content

Commit

Permalink
Merge pull request #57846 from dims/fix-external-address-parsing-unde…
Browse files Browse the repository at this point in the history
…r-ipv6

Automatic merge from submit-queue (batch tested with PRs 56315, 57846). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fix ExternalAddress parsing problem under IPv6

**What this PR does / why we need it**:
`!strings.Contains(host, ":") ` will fail miserably under ipv6

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```

Kubernetes-commit: fa2ea5284e608854c9ad5e00699ee013ad3ae886
  • Loading branch information
k8s-publishing-bot committed Jan 4, 2018
2 parents 37e1a73 + b1be39c commit 5390b33
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 5390b33

Please sign in to comment.