Skip to content

Commit

Permalink
Use net.JoinHostPort instead of concatenation (knative#4788)
Browse files Browse the repository at this point in the history
This handles ipv6 addresses correctly.
  • Loading branch information
jonjohnsonjr authored and knative-prow-robot committed Jul 17, 2019
1 parent bc20336 commit 936b4b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/activator/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"errors"
"fmt"
"net"
"net/http"
"net/http/httputil"
"net/url"
Expand Down Expand Up @@ -317,7 +318,7 @@ func (a *activationHandler) serviceHostName(rev *v1alpha1.Revision, serviceName

// Use the ClusterIP directly to elide DNS lookup, which both adds latency
// and hurts reliability when routing through the activator.
return svc.Spec.ClusterIP + ":" + strconv.Itoa(port), nil
return net.JoinHostPort(svc.Spec.ClusterIP, strconv.Itoa(port)), nil
}

func sendError(err error, w http.ResponseWriter) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/queue/health/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func HTTPProbe(config HTTPProbeConfigOptions) error {
}
url := url.URL{
Scheme: string(config.Scheme),
Host: config.Host + ":" + config.Port.String(),
Host: net.JoinHostPort(config.Host, config.Port.String()),
Path: config.Path,
}
req, err := http.NewRequest(http.MethodGet, url.String(), nil)
Expand Down

0 comments on commit 936b4b0

Please sign in to comment.