diff options
author | 2020-09-24 11:30:39 -0700 | |
---|---|---|
committer | 2020-09-24 20:30:39 +0200 | |
commit | 9798dd067f53a74e3777cff539b2f01617c107c6 (patch) | |
tree | fac3bbc495c9a7f78fd9a847fb44533bd6367d9a /plugin/file/notify.go | |
parent | 279194f2e45c9dfeccafe95e515e0aced0ea8bdc (diff) | |
download | coredns-9798dd067f53a74e3777cff539b2f01617c107c6.tar.gz coredns-9798dd067f53a74e3777cff539b2f01617c107c6.tar.zst coredns-9798dd067f53a74e3777cff539b2f01617c107c6.zip |
Cherry-pick: Implement notifies for transfer plugin (#3972) (#4142)
* Implement notifies for transfer plugin (#3972)
* Fix notifies in transfer plugin
Signed-off-by: Miek Gieben <miek@miek.nl>
* Make it compile
Signed-off-by: Miek Gieben <miek@miek.nl>
* Port more plugins
Signed-off-by: Miek Gieben <miek@miek.nl>
* golint
Signed-off-by: Miek Gieben <miek@miek.nl>
* Fix tests
Signed-off-by: Miek Gieben <miek@miek.nl>
* Fix notifies in transfer plugin
Signed-off-by: Miek Gieben <miek@miek.nl>
* Make it compile
Signed-off-by: Miek Gieben <miek@miek.nl>
* Port more plugins
Signed-off-by: Miek Gieben <miek@miek.nl>
* golint
Signed-off-by: Miek Gieben <miek@miek.nl>
* Fix tests
Signed-off-by: Miek Gieben <miek@miek.nl>
* Fix tests
Signed-off-by: Miek Gieben <miek@miek.nl>
* really fix test
Signed-off-by: Miek Gieben <miek@miek.nl>
* Implement ixfr fallback and unify file and auto for transfering
Signed-off-by: Miek Gieben <miek@miek.nl>
* Add transfer tests
copied and modified from #3452
Signed-off-by: Miek Gieben <miek@miek.nl>
* Test correct selection of plugin
Signed-off-by: Miek Gieben <miek@miek.nl>
* add upstream back in
Signed-off-by: Miek Gieben <miek@miek.nl>
* Implement ixfr fallback and unify file and auto for transfering
Signed-off-by: Miek Gieben <miek@miek.nl>
* fix test
Signed-off-by: Miek Gieben <miek@miek.nl>
* properly merge
Signed-off-by: Miek Gieben <miek@miek.nl>
* Remove plugin/kubernetes/setup_transfer_test.go
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Co-authored-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/file/notify.go')
-rw-r--r-- | plugin/file/notify.go | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/plugin/file/notify.go b/plugin/file/notify.go index 83d73ee6f..7d4e35cc3 100644 --- a/plugin/file/notify.go +++ b/plugin/file/notify.go @@ -1,10 +1,8 @@ package file import ( - "fmt" "net" - "github.com/coredns/coredns/plugin/pkg/rcode" "github.com/coredns/coredns/request" "github.com/miekg/dns" @@ -33,48 +31,3 @@ func (z *Zone) isNotify(state request.Request) bool { } return false } - -// Notify will send notifies to all configured TransferTo IP addresses. -func (z *Zone) Notify() { - go notify(z.origin, z.TransferTo) -} - -// notify sends notifies to the configured remote servers. It will try up to three times -// before giving up on a specific remote. We will sequentially loop through "to" -// until they all have replied (or have 3 failed attempts). -func notify(zone string, to []string) error { - m := new(dns.Msg) - m.SetNotify(zone) - c := new(dns.Client) - - for _, t := range to { - if t == "*" { - continue - } - if err := notifyAddr(c, m, t); err != nil { - log.Error(err.Error()) - } - } - log.Infof("Sent notifies for zone %q to %v", zone, to) - return nil -} - -func notifyAddr(c *dns.Client, m *dns.Msg, s string) error { - var err error - - code := dns.RcodeServerFailure - for i := 0; i < 3; i++ { - ret, _, err := c.Exchange(m, s) - if err != nil { - continue - } - code = ret.Rcode - if code == dns.RcodeSuccess { - return nil - } - } - if err != nil { - return fmt.Errorf("notify for zone %q was not accepted by %q: %q", m.Question[0].Name, s, err) - } - return fmt.Errorf("notify for zone %q was not accepted by %q: rcode was %q", m.Question[0].Name, s, rcode.ToString(code)) -} |