Resolve TXT records via CNAME (#3557)

* Add test case for TXT lookup via CNAME

Signed-off-by: Jonathan Nagy <nagytech@users.noreply.github.com>

* Return HostType of explicit TXT records

Signed-off-by: Jonathan Nagy <nagytech@users.noreply.github.com>

* Adapt TXT method lookup to allow lookup via CNAME

Signed-off-by: Jonathan Nagy <nagytech@users.noreply.github.com>

* Implement lookup of TXT records via CNAME

Signed-off-by: Jonathan Nagy <nagytech@users.noreply.github.com>
This commit is contained in:
Jonathan Nagy
2020-01-04 00:16:04 +11:00
committed by Miek Gieben
parent acac649c1b
commit e3266d24f7
6 changed files with 80 additions and 12 deletions

View File

@@ -177,11 +177,9 @@ func (e *Etcd) TTL(kv *mvccpb.KeyValue, serv *msg.Service) uint32 {
}
// shouldInclude returns true if the service should be included in a list of records, given the qType. For all the
// currently supported lookup types, the only one to allow for an empty Host field in the service are TXT records.
// Similarly, the TXT record in turn requires the Text field to be set.
// currently supported lookup types, the only one to allow for an empty Host field in the service are TXT records
// which resolve directly. If a TXT record is being resolved by CNAME, then we expect the Host field to have a
// value while the TXT field will be empty.
func shouldInclude(serv *msg.Service, qType uint16) bool {
if qType == dns.TypeTXT {
return serv.Text != ""
}
return serv.Host != ""
return (qType == dns.TypeTXT && serv.Text != "") || serv.Host != ""
}