dns: prefixing txt record lookup with "_grpc_config." (#2691)

This commit is contained in:
lyuxuan
2019-03-14 13:40:48 -07:00
committed by GitHub
parent 7c93bdf75a
commit 2098091c81
2 changed files with 7 additions and 5 deletions

View File

@ -47,6 +47,8 @@ const (
defaultFreq = time.Minute * 30
defaultDNSSvrPort = "53"
golang = "GO"
// txtPrefix is the prefix string to be prepended to the host name for txt record lookup.
txtPrefix = "_grpc_config."
// In DNS, service config is encoded in a TXT record via the mechanism
// described in RFC-1464 using the attribute name grpc_config.
txtAttribute = "grpc_config="
@ -282,7 +284,7 @@ func (d *dnsResolver) lookupSRV() []resolver.Address {
}
func (d *dnsResolver) lookupTXT() string {
ss, err := d.resolver.LookupTXT(d.ctx, d.host)
ss, err := d.resolver.LookupTXT(d.ctx, txtPrefix+d.host)
if err != nil {
grpclog.Infof("grpc: failed dns TXT record lookup due to %v.\n", err)
return ""

View File

@ -574,10 +574,10 @@ var scs = []string{
// scLookupTbl is a set, which contains targets that have service config. Target
// not in this set should not have service config.
var scLookupTbl = map[string]bool{
"foo.bar.com": true,
"srv.ipv4.single.fake": true,
"srv.ipv4.multi.fake": true,
"no.attribute": true,
txtPrefix + "foo.bar.com": true,
txtPrefix + "srv.ipv4.single.fake": true,
txtPrefix + "srv.ipv4.multi.fake": true,
txtPrefix + "no.attribute": true,
}
// generateSCF generates a slice of strings (aggregately representing a single