mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
plugin/k8s_external: Persist tc bit from lookup to client response (#4716)
* persist reponse tc bit from lookup to client Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
@@ -99,9 +99,9 @@ func (e *External) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
|
|||||||
|
|
||||||
switch state.QType() {
|
switch state.QType() {
|
||||||
case dns.TypeA:
|
case dns.TypeA:
|
||||||
m.Answer = e.a(ctx, svc, state)
|
m.Answer, m.Truncated = e.a(ctx, svc, state)
|
||||||
case dns.TypeAAAA:
|
case dns.TypeAAAA:
|
||||||
m.Answer = e.aaaa(ctx, svc, state)
|
m.Answer, m.Truncated = e.aaaa(ctx, svc, state)
|
||||||
case dns.TypeSRV:
|
case dns.TypeSRV:
|
||||||
m.Answer, m.Extra = e.srv(ctx, svc, state)
|
m.Answer, m.Extra = e.srv(ctx, svc, state)
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ var tests = []test.Case{
|
|||||||
{
|
{
|
||||||
Qname: "svc1.testns.example.com.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess,
|
Qname: "svc1.testns.example.com.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess,
|
||||||
Answer: []dns.RR{test.SRV("svc1.testns.example.com. 5 IN SRV 0 100 80 svc1.testns.example.com.")},
|
Answer: []dns.RR{test.SRV("svc1.testns.example.com. 5 IN SRV 0 100 80 svc1.testns.example.com.")},
|
||||||
Extra: []dns.RR{test.A("svc1.testns.example.com. 5 IN A 1.2.3.4")},
|
Extra: []dns.RR{test.A("svc1.testns.example.com. 5 IN A 1.2.3.4")},
|
||||||
},
|
},
|
||||||
// SRV Service Not udp/tcp
|
// SRV Service Not udp/tcp
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e *External) a(ctx context.Context, services []msg.Service, state request.Request) (records []dns.RR) {
|
func (e *External) a(ctx context.Context, services []msg.Service, state request.Request) (records []dns.RR, truncated bool) {
|
||||||
dup := make(map[string]struct{})
|
dup := make(map[string]struct{})
|
||||||
|
|
||||||
for _, s := range services {
|
for _, s := range services {
|
||||||
@@ -23,6 +23,9 @@ func (e *External) a(ctx context.Context, services []msg.Service, state request.
|
|||||||
records = append(records, rr)
|
records = append(records, rr)
|
||||||
if resp, err := e.upstream.Lookup(ctx, state, dns.Fqdn(s.Host), dns.TypeA); err == nil {
|
if resp, err := e.upstream.Lookup(ctx, state, dns.Fqdn(s.Host), dns.TypeA); err == nil {
|
||||||
records = append(records, resp.Answer...)
|
records = append(records, resp.Answer...)
|
||||||
|
if resp.Truncated {
|
||||||
|
truncated = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case dns.TypeA:
|
case dns.TypeA:
|
||||||
@@ -37,10 +40,10 @@ func (e *External) a(ctx context.Context, services []msg.Service, state request.
|
|||||||
// nada
|
// nada
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return records
|
return records, truncated
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *External) aaaa(ctx context.Context, services []msg.Service, state request.Request) (records []dns.RR) {
|
func (e *External) aaaa(ctx context.Context, services []msg.Service, state request.Request) (records []dns.RR, truncated bool) {
|
||||||
dup := make(map[string]struct{})
|
dup := make(map[string]struct{})
|
||||||
|
|
||||||
for _, s := range services {
|
for _, s := range services {
|
||||||
@@ -53,6 +56,9 @@ func (e *External) aaaa(ctx context.Context, services []msg.Service, state reque
|
|||||||
records = append(records, rr)
|
records = append(records, rr)
|
||||||
if resp, err := e.upstream.Lookup(ctx, state, dns.Fqdn(s.Host), dns.TypeAAAA); err == nil {
|
if resp, err := e.upstream.Lookup(ctx, state, dns.Fqdn(s.Host), dns.TypeAAAA); err == nil {
|
||||||
records = append(records, resp.Answer...)
|
records = append(records, resp.Answer...)
|
||||||
|
if resp.Truncated {
|
||||||
|
truncated = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case dns.TypeA:
|
case dns.TypeA:
|
||||||
@@ -67,7 +73,7 @@ func (e *External) aaaa(ctx context.Context, services []msg.Service, state reque
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return records
|
return records, truncated
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *External) srv(ctx context.Context, services []msg.Service, state request.Request) (records, extra []dns.RR) {
|
func (e *External) srv(ctx context.Context, services []msg.Service, state request.Request) (records, extra []dns.RR) {
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ func (e *External) Transfer(zone string, serial uint32) (<-chan []dns.RR, error)
|
|||||||
if svcs[i].TargetStrip == 0 {
|
if svcs[i].TargetStrip == 0 {
|
||||||
// Add Service A/AAAA records
|
// Add Service A/AAAA records
|
||||||
s := request.Request{Req: &dns.Msg{Question: []dns.Question{{Name: name}}}}
|
s := request.Request{Req: &dns.Msg{Question: []dns.Question{{Name: name}}}}
|
||||||
as := e.a(ctx, []msg.Service{svcs[i]}, s)
|
as, _ := e.a(ctx, []msg.Service{svcs[i]}, s)
|
||||||
if len(as) > 0 {
|
if len(as) > 0 {
|
||||||
ch <- as
|
ch <- as
|
||||||
}
|
}
|
||||||
aaaas := e.aaaa(ctx, []msg.Service{svcs[i]}, s)
|
aaaas, _ := e.aaaa(ctx, []msg.Service{svcs[i]}, s)
|
||||||
if len(aaaas) > 0 {
|
if len(aaaas) > 0 {
|
||||||
ch <- aaaas
|
ch <- aaaas
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user