mirror of
https://github.com/coredns/coredns.git
synced 2026-07-12 10:40:10 -04:00
plugin/transfer: configure notify source address (#8192)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user