* plugin/transfer: only allow outgoing axfr over tcp Return refused when the query comes in over udp. No need to add a new test case as the current crop needed to be changed to use TCP. Fixes: #4450 Signed-off-by: Miek Gieben <miek@miek.nl> * transfer tests: this needs tcp as well Signed-off-by: Miek Gieben <miek@miek.nl>
31 lines
589 B
Go
31 lines
589 B
Go
package transfer
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/coredns/coredns/plugin/test"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
type badwriter struct {
|
|
dns.ResponseWriter
|
|
count int
|
|
}
|
|
|
|
func (w *badwriter) WriteMsg(res *dns.Msg) error { return fmt.Errorf("failed to write msg") }
|
|
|
|
func TestWriteMessageFailed(t *testing.T) {
|
|
transfer := newTestTransfer()
|
|
ctx := context.TODO()
|
|
w := &badwriter{ResponseWriter: &test.ResponseWriter{TCP: true}}
|
|
m := &dns.Msg{}
|
|
m.SetAxfr("example.org.")
|
|
|
|
_, err := transfer.ServeDNS(ctx, w, m)
|
|
if err == nil {
|
|
t.Error("Expected error, got none")
|
|
}
|
|
}
|