Overwrite authority if creds servername is specified

This commit is contained in:
Menghan Li
2016-09-02 16:54:17 -07:00
parent 52f6504dc2
commit a00cbfeab5
3 changed files with 39 additions and 11 deletions

View File

@ -322,11 +322,16 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
if ok {
go cc.lbWatcher()
}
colonPos := strings.LastIndex(target, ":")
if colonPos == -1 {
colonPos = len(target)
creds := cc.dopts.copts.TransportCredentials
if creds != nil && creds.Info().ServerName != "" {
cc.authority = creds.Info().ServerName
} else {
colonPos := strings.LastIndex(target, ":")
if colonPos == -1 {
colonPos = len(target)
}
cc.authority = target[:colonPos]
}
cc.authority = target[:colonPos]
return cc, nil
}