plugin/transfer: configure notify source address (#8192)

Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
This commit is contained in:
houyuwushang
2026-06-29 12:15:16 +08:00
committed by GitHub
parent 45a20ddcf1
commit 02f28345d1
6 changed files with 104 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ package transfer
import (
"fmt"
"net"
"github.com/coredns/coredns/plugin/pkg/rcode"
@@ -16,13 +17,13 @@ func (t *Transfer) Notify(zone string) error {
m := new(dns.Msg)
m.SetNotify(zone)
c := new(dns.Client)
x := longestMatch(t.xfrs, zone)
if x == nil {
// return without error if there is no matching zone
return nil
}
c := notifyClient(x)
var err1 error
for _, t := range x.to {
@@ -37,6 +38,14 @@ func (t *Transfer) Notify(zone string) error {
return err1 // this only captures the last error
}
func notifyClient(x *xfr) *dns.Client {
c := new(dns.Client)
if x != nil && x.source != nil {
c.Dialer = &net.Dialer{LocalAddr: &net.UDPAddr{IP: x.source}}
}
return c
}
func sendNotify(c *dns.Client, m *dns.Msg, s string) error {
var err error
var ret *dns.Msg