mirror of https://github.com/status-im/consul.git
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)
|
reqType := parseRequestType(req)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
// Virtual IPs and Address requests
|
|
||||||
// both return IPs with empty targets
|
|
||||||
case (reqType == requestTypeAddress || result.Type == discovery.ResultTypeVirtual) &&
|
case (reqType == requestTypeAddress || result.Type == discovery.ResultTypeVirtual) &&
|
||||||
serviceAddress.IsEmptyString() && nodeAddress.IsIP():
|
serviceAddress.IsEmptyString() && nodeAddress.IsIP():
|
||||||
a, e := getAnswerExtrasForIP(qName, nodeAddress, req.Question[0], reqType,
|
a, e := getAnswerExtrasForIP(qName, nodeAddress, req.Question[0], reqType,
|
||||||
|
@ -894,13 +892,19 @@ func (r *Router) getAnswerExtrasForAddressAndTarget(nodeAddress *dnsAddress, ser
|
||||||
answer = append(answer, a...)
|
answer = append(answer, a...)
|
||||||
extra = append(extra, e...)
|
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)
|
canonicalNodeName := canonicalNameForResult(result.Type, result.Node.Name, domain, result.Tenancy, result.PortName)
|
||||||
a, e := getAnswerExtrasForIP(canonicalNodeName, nodeAddress, req.Question[0], reqType,
|
a, e := getAnswerExtrasForIP(canonicalNodeName, nodeAddress, req.Question[0], reqType,
|
||||||
result, ttl, domain)
|
result, ttl, domain)
|
||||||
answer = append(answer, a...)
|
answer = append(answer, a...)
|
||||||
extra = append(extra, e...)
|
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():
|
case serviceAddress.IsEmptyString() && nodeAddress.IsEmptyString():
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
||||||
|
@ -1111,7 +1115,7 @@ func (r *Router) makeRecordFromFQDN(fqdn string, result *discovery.Result,
|
||||||
MORE_REC:
|
MORE_REC:
|
||||||
for _, rr := range more {
|
for _, rr := range more {
|
||||||
switch rr.Header().Rrtype {
|
switch rr.Header().Rrtype {
|
||||||
case dns.TypeCNAME, dns.TypeA, dns.TypeAAAA:
|
case dns.TypeCNAME, dns.TypeA, dns.TypeAAAA, dns.TypeTXT:
|
||||||
// set the TTL manually
|
// set the TTL manually
|
||||||
rr.Header().Ttl = ttl
|
rr.Header().Ttl = ttl
|
||||||
additional = append(additional, rr)
|
additional = append(additional, rr)
|
||||||
|
|
|
@ -275,7 +275,7 @@ func TestDNS_NodeLookup_CNAME(t *testing.T) {
|
||||||
})
|
})
|
||||||
defer recursor.Shutdown()
|
defer recursor.Shutdown()
|
||||||
|
|
||||||
for name, experimentsHCL := range getVersionHCL(false) {
|
for name, experimentsHCL := range getVersionHCL(true) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
a := NewTestAgent(t, `
|
a := NewTestAgent(t, `
|
||||||
recursors = ["`+recursor.Addr+`"]
|
recursors = ["`+recursor.Addr+`"]
|
||||||
|
@ -594,7 +594,7 @@ func TestDNS_NodeLookup_TTL(t *testing.T) {
|
||||||
})
|
})
|
||||||
defer recursor.Shutdown()
|
defer recursor.Shutdown()
|
||||||
|
|
||||||
for name, experimentsHCL := range getVersionHCL(false) {
|
for name, experimentsHCL := range getVersionHCL(true) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
a := NewTestAgent(t, `
|
a := NewTestAgent(t, `
|
||||||
recursors = ["`+recursor.Addr+`"]
|
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) {
|
func TestDNS_ServiceLookup_ServiceAddress_SRV(t *testing.T) {
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("too slow for testing.Short")
|
t.Skip("too slow for testing.Short")
|
||||||
|
|
Loading…
Reference in New Issue