Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: use "localhost:port" as authority if target is ":port" #4017

Merged
merged 8 commits into from Nov 12, 2020
2 changes: 2 additions & 0 deletions clientconn.go
Expand Up @@ -259,6 +259,8 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
cc.authority = cc.dopts.authority
} else if strings.HasPrefix(cc.target, "unix:") {
cc.authority = "localhost"
} else if strings.HasPrefix(cc.parsedTarget.Endpoint, ":") {
cc.authority = "localhost" + cc.parsedTarget.Endpoint
} else {
// Use endpoint from "scheme://authority/endpoint" as the default
// authority for ClientConn.
Expand Down