aboutsummaryrefslogtreecommitdiff
path: root/plugin/auto/xfr.go
blob: e6a9ba5a58631038ab1ca297c30fe1d0d7477225 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package auto

import (
	"github.com/coredns/coredns/plugin/transfer"

	"github.com/miekg/dns"
)

// Transfer implements the transfer.Transfer interface.
func (a Auto) Transfer(zone string, serial uint32) (<-chan []dns.RR, error) {
	a.Zones.RLock()
	z, ok := a.Zones.Z[zone]
	a.Zones.RUnlock()

	if !ok || z == nil {
		return nil, transfer.ErrNotAuthoritative
	}
	return z.Transfer(serial)
}

// Notify sends notifies for all zones with secondaries configured with the transfer plugin
func (a Auto) Notify() error {
	var err error
	for _, origin := range a.Zones.Names() {
		e := a.transfer.Notify(origin)
		if e != nil {
			err = e
		}
	}
	return err
}