mirror of
https://github.com/status-im/consul.git
synced 2025-01-18 09:41:32 +00:00
NET-7631 - Fix Node records that point to external/ non-IP addresses (#20491)
* NET-7630 - Fix TXT record creation on node queries * NET-7631 - Fix Node records that point to external/ non-IP addresses * NET-7630 - Fix TXT record creation on node queries
This commit is contained in:
parent
7d4deda640
commit
3bf999e46b
@ -885,8 +885,6 @@ func (r *Router) getAnswerExtrasForAddressAndTarget(nodeAddress *dnsAddress, ser
|
||||
reqType := parseRequestType(req)
|
||||
|
||||
switch {
|
||||
// Virtual IPs and Address requests
|
||||
// both return IPs with empty targets
|
||||
case (reqType == requestTypeAddress || result.Type == discovery.ResultTypeVirtual) &&
|
||||
serviceAddress.IsEmptyString() && nodeAddress.IsIP():
|
||||
a, e := getAnswerExtrasForIP(qName, nodeAddress, req.Question[0], reqType,
|
||||
@ -894,13 +892,19 @@ func (r *Router) getAnswerExtrasForAddressAndTarget(nodeAddress *dnsAddress, ser
|
||||
answer = append(answer, a...)
|
||||
extra = append(extra, e...)
|
||||
|
||||
case result.Type == discovery.ResultTypeNode:
|
||||
case result.Type == discovery.ResultTypeNode && nodeAddress.IsIP():
|
||||
canonicalNodeName := canonicalNameForResult(result.Type, result.Node.Name, domain, result.Tenancy, result.PortName)
|
||||
a, e := getAnswerExtrasForIP(canonicalNodeName, nodeAddress, req.Question[0], reqType,
|
||||
result, ttl, domain)
|
||||
answer = append(answer, a...)
|
||||
extra = append(extra, e...)
|
||||
|
||||
case result.Type == discovery.ResultTypeNode && !nodeAddress.IsIP():
|
||||
a, e := r.makeRecordFromFQDN(serviceAddress.FQDN(), result, req, reqCtx, cfg,
|
||||
ttl, remoteAddress, maxRecursionLevel)
|
||||
answer = append(answer, a...)
|
||||
extra = append(extra, e...)
|
||||
|
||||
case serviceAddress.IsEmptyString() && nodeAddress.IsEmptyString():
|
||||
return nil, nil
|
||||
|
||||
@ -1111,7 +1115,7 @@ func (r *Router) makeRecordFromFQDN(fqdn string, result *discovery.Result,
|
||||
MORE_REC:
|
||||
for _, rr := range more {
|
||||
switch rr.Header().Rrtype {
|
||||
case dns.TypeCNAME, dns.TypeA, dns.TypeAAAA:
|
||||
case dns.TypeCNAME, dns.TypeA, dns.TypeAAAA, dns.TypeTXT:
|
||||
// set the TTL manually
|
||||
rr.Header().Ttl = ttl
|
||||
additional = append(additional, rr)
|
||||
|
@ -275,7 +275,7 @@ func TestDNS_NodeLookup_CNAME(t *testing.T) {
|
||||
})
|
||||
defer recursor.Shutdown()
|
||||
|
||||
for name, experimentsHCL := range getVersionHCL(false) {
|
||||
for name, experimentsHCL := range getVersionHCL(true) {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
a := NewTestAgent(t, `
|
||||
recursors = ["`+recursor.Addr+`"]
|
||||
@ -594,7 +594,7 @@ func TestDNS_NodeLookup_TTL(t *testing.T) {
|
||||
})
|
||||
defer recursor.Shutdown()
|
||||
|
||||
for name, experimentsHCL := range getVersionHCL(false) {
|
||||
for name, experimentsHCL := range getVersionHCL(true) {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
a := NewTestAgent(t, `
|
||||
recursors = ["`+recursor.Addr+`"]
|
||||
|
@ -1328,7 +1328,7 @@ func TestDNS_AltDomain_ServiceLookup_ServiceAddress_A(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO (v2-dns): NET-7631 - Implement external CNAME references
|
||||
// TODO (v2-dns): NET-7632 - Fix node and prepared query lookups when question name has a period in it
|
||||
func TestDNS_ServiceLookup_ServiceAddress_SRV(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("too slow for testing.Short")
|
||||
|
Loading…
x
Reference in New Issue
Block a user