mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
plugin/kubernetes: Only answer transfer requests for authoritative zones (#4802)
* check for zone match Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
@@ -18,6 +18,10 @@ import (
|
|||||||
|
|
||||||
// Transfer implements the transfer.Transfer interface.
|
// Transfer implements the transfer.Transfer interface.
|
||||||
func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, error) {
|
func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, error) {
|
||||||
|
match := plugin.Zones(k.Zones).Matches(zone)
|
||||||
|
if match == "" {
|
||||||
|
return nil, transfer.ErrNotAuthoritative
|
||||||
|
}
|
||||||
// state is not used here, hence the empty request.Request{]
|
// state is not used here, hence the empty request.Request{]
|
||||||
soa, err := plugin.SOA(context.TODO(), k, zone, request.Request{}, plugin.Options{})
|
soa, err := plugin.SOA(context.TODO(), k, zone, request.Request{}, plugin.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -5,9 +5,26 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/coredns/coredns/plugin/transfer"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestKubernetesTransferNonAuthZone(t *testing.T) {
|
||||||
|
k := New([]string{"cluster.local."})
|
||||||
|
k.APIConn = &APIConnServeTest{}
|
||||||
|
k.Namespaces = map[string]struct{}{"testns": {}, "kube-system": {}}
|
||||||
|
k.localIPs = []net.IP{net.ParseIP("10.0.0.10")}
|
||||||
|
|
||||||
|
dnsmsg := &dns.Msg{}
|
||||||
|
dnsmsg.SetAxfr("example.com")
|
||||||
|
|
||||||
|
_, err := k.Transfer("example.com", 0)
|
||||||
|
if err != transfer.ErrNotAuthoritative {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestKubernetesAXFR(t *testing.T) {
|
func TestKubernetesAXFR(t *testing.T) {
|
||||||
k := New([]string{"cluster.local."})
|
k := New([]string{"cluster.local."})
|
||||||
k.APIConn = &APIConnServeTest{}
|
k.APIConn = &APIConnServeTest{}
|
||||||
|
|||||||
Reference in New Issue
Block a user