mirror of
https://github.com/coredns/coredns.git
synced 2026-07-18 05:30:13 -04:00
plugin/secondary: serve catalog member zones (#8230)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
This commit is contained in:
46
plugin/secondary/zones.go
Normal file
46
plugin/secondary/zones.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package secondary
|
||||
|
||||
import (
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/plugin/file"
|
||||
)
|
||||
|
||||
func (s *Secondary) lookupZone(qname string) (string, *file.Zone, bool) {
|
||||
s.zoneMu.RLock()
|
||||
defer s.zoneMu.RUnlock()
|
||||
|
||||
zone := plugin.Zones(s.Names).Matches(qname)
|
||||
if zone == "" {
|
||||
return "", nil, false
|
||||
}
|
||||
z, ok := s.Z[zone]
|
||||
if !ok {
|
||||
return zone, nil, true
|
||||
}
|
||||
return zone, z, true
|
||||
}
|
||||
|
||||
func (s *Secondary) zoneName(z *file.Zone) string {
|
||||
s.zoneMu.RLock()
|
||||
defer s.zoneMu.RUnlock()
|
||||
|
||||
return s.zoneNames[z]
|
||||
}
|
||||
|
||||
func (s *Secondary) stopDynamicZones() {
|
||||
s.zoneMu.Lock()
|
||||
defer s.zoneMu.Unlock()
|
||||
|
||||
for _, dyn := range s.dynamicZones {
|
||||
dyn.stopOnce.Do(func() { close(dyn.shutdown) })
|
||||
}
|
||||
}
|
||||
|
||||
func removeZoneName(names []string, name string) []string {
|
||||
for i, n := range names {
|
||||
if n == name {
|
||||
return append(names[:i], names[i+1:]...)
|
||||
}
|
||||
}
|
||||
return names
|
||||
}
|
||||
Reference in New Issue
Block a user