Commit e60c1791 authored by Chris O'Haver's avatar Chris O'Haver Committed by GitHub

plugin/k8s_external: Set authoritative bit in responses (#5284)

set authoritative bit in responses
Signed-off-by: default avatarChris O'Haver <cohaver@infoblox.com>
parent 83021637
......@@ -11,6 +11,7 @@ import (
func (e *External) serveApex(state request.Request) (int, error) {
m := new(dns.Msg)
m.SetReply(state.Req)
m.Authoritative = true
switch state.QType() {
case dns.TypeSOA:
m.Answer = []dns.RR{e.soa(state)}
......@@ -37,6 +38,7 @@ func (e *External) serveSubApex(state request.Request) (int, error) {
m := new(dns.Msg)
m.SetReply(state.Req)
m.Authoritative = true
// base is either dns. of ns1.dns (or another name), if it's longer return nxdomain
switch labels := dns.CountLabel(base); labels {
......
......@@ -41,6 +41,9 @@ func TestApex(t *testing.T) {
if resp == nil {
t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name)
}
if !resp.Authoritative {
t.Error("Expected authoritative answer")
}
if err := test.SortAndCheck(resp, tc); err != nil {
t.Error(err)
}
......
......@@ -89,6 +89,7 @@ func (e *External) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
m := new(dns.Msg)
m.SetReply(state.Req)
m.Authoritative = true
if len(svc) == 0 {
m.Rcode = rcode
......
......@@ -45,6 +45,9 @@ func TestExternal(t *testing.T) {
if resp == nil {
t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name)
}
if !resp.Authoritative {
t.Error("Expected authoritative answer")
}
if err = test.SortAndCheck(resp, tc); err != nil {
t.Error(err)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment