2022-11-03 18:39:37 +01:00
|
|
|
package dns
|
|
|
|
|
2023-06-12 14:43:55 +02:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"net/netip"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
"github.com/miekg/dns"
|
|
|
|
"github.com/mitchellh/hashstructure/v2"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
|
|
|
|
nbdns "github.com/netbirdio/netbird/dns"
|
|
|
|
)
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
// ReadyListener is a notification mechanism what indicate the server is ready to handle host dns address changes
|
|
|
|
type ReadyListener interface {
|
|
|
|
OnReady()
|
|
|
|
}
|
2022-11-03 18:39:37 +01:00
|
|
|
|
2022-11-07 15:38:21 +01:00
|
|
|
// Server is a dns server interface
|
|
|
|
type Server interface {
|
2023-06-15 12:25:18 +02:00
|
|
|
Initialize() error
|
2022-11-07 15:38:21 +01:00
|
|
|
Stop()
|
2023-06-12 14:43:55 +02:00
|
|
|
DnsIP() string
|
2022-11-07 15:38:21 +01:00
|
|
|
UpdateDNSServer(serial uint64, update nbdns.Config) error
|
2023-07-14 21:56:22 +02:00
|
|
|
OnUpdatedHostDNSServer(strings []string)
|
2022-11-07 15:38:21 +01:00
|
|
|
}
|
2023-06-12 14:43:55 +02:00
|
|
|
|
|
|
|
type registeredHandlerMap map[string]handlerWithStop
|
|
|
|
|
|
|
|
// DefaultServer dns server object
|
|
|
|
type DefaultServer struct {
|
|
|
|
ctx context.Context
|
|
|
|
ctxCancel context.CancelFunc
|
|
|
|
mux sync.Mutex
|
2023-07-14 21:56:22 +02:00
|
|
|
service service
|
2023-06-12 14:43:55 +02:00
|
|
|
dnsMuxMap registeredHandlerMap
|
|
|
|
localResolver *localResolver
|
2023-07-14 21:56:22 +02:00
|
|
|
wgInterface WGIface
|
2023-06-12 14:43:55 +02:00
|
|
|
hostManager hostManager
|
|
|
|
updateSerial uint64
|
|
|
|
previousConfigHash uint64
|
|
|
|
currentConfig hostDNSConfig
|
2023-07-14 21:56:22 +02:00
|
|
|
|
|
|
|
// permanent related properties
|
|
|
|
permanent bool
|
|
|
|
hostsDnsList []string
|
|
|
|
hostsDnsListLock sync.Mutex
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type handlerWithStop interface {
|
|
|
|
dns.Handler
|
|
|
|
stop()
|
|
|
|
}
|
|
|
|
|
|
|
|
type muxUpdate struct {
|
|
|
|
domain string
|
|
|
|
handler handlerWithStop
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewDefaultServer returns a new dns server
|
2023-07-14 21:56:22 +02:00
|
|
|
func NewDefaultServer(ctx context.Context, wgInterface WGIface, customAddress string) (*DefaultServer, error) {
|
2023-06-12 14:43:55 +02:00
|
|
|
var addrPort *netip.AddrPort
|
|
|
|
if customAddress != "" {
|
|
|
|
parsedAddrPort, err := netip.ParseAddrPort(customAddress)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("unable to parse the custom dns address, got error: %s", err)
|
|
|
|
}
|
|
|
|
addrPort = &parsedAddrPort
|
|
|
|
}
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
var dnsService service
|
|
|
|
if wgInterface.IsUserspaceBind() {
|
|
|
|
dnsService = newServiceViaMemory(wgInterface)
|
|
|
|
} else {
|
|
|
|
dnsService = newServiceViaListener(wgInterface, addrPort)
|
|
|
|
}
|
2023-06-12 14:43:55 +02:00
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
return newDefaultServer(ctx, wgInterface, dnsService), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewDefaultServerPermanentUpstream returns a new dns server. It optimized for mobile systems
|
|
|
|
func NewDefaultServerPermanentUpstream(ctx context.Context, wgInterface WGIface, hostsDnsList []string) *DefaultServer {
|
|
|
|
log.Debugf("host dns address list is: %v", hostsDnsList)
|
|
|
|
ds := newDefaultServer(ctx, wgInterface, newServiceViaMemory(wgInterface))
|
|
|
|
ds.permanent = true
|
|
|
|
ds.hostsDnsList = hostsDnsList
|
|
|
|
ds.addHostRootZone()
|
|
|
|
setServerDns(ds)
|
|
|
|
return ds
|
|
|
|
}
|
|
|
|
|
|
|
|
func newDefaultServer(ctx context.Context, wgInterface WGIface, dnsService service) *DefaultServer {
|
|
|
|
ctx, stop := context.WithCancel(ctx)
|
2023-06-12 14:43:55 +02:00
|
|
|
defaultServer := &DefaultServer{
|
|
|
|
ctx: ctx,
|
|
|
|
ctxCancel: stop,
|
2023-07-14 21:56:22 +02:00
|
|
|
service: dnsService,
|
2023-06-12 14:43:55 +02:00
|
|
|
dnsMuxMap: make(registeredHandlerMap),
|
|
|
|
localResolver: &localResolver{
|
|
|
|
registeredMap: make(registrationMap),
|
|
|
|
},
|
2023-07-14 21:56:22 +02:00
|
|
|
wgInterface: wgInterface,
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
return defaultServer
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
// Initialize instantiate host manager and the dns service
|
2023-06-15 12:25:18 +02:00
|
|
|
func (s *DefaultServer) Initialize() (err error) {
|
|
|
|
s.mux.Lock()
|
|
|
|
defer s.mux.Unlock()
|
|
|
|
|
|
|
|
if s.hostManager != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
if s.permanent {
|
|
|
|
err = s.service.Listen()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-06-22 14:59:21 +02:00
|
|
|
}
|
2023-07-14 21:56:22 +02:00
|
|
|
|
2023-06-15 12:25:18 +02:00
|
|
|
s.hostManager, err = newHostManager(s.wgInterface)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-06-22 14:59:21 +02:00
|
|
|
// DnsIP returns the DNS resolver server IP address
|
|
|
|
//
|
|
|
|
// When kernel space interface used it return real DNS server listener IP address
|
|
|
|
// For bind interface, fake DNS resolver address returned (second last IP address from Nebird network)
|
2023-06-12 14:43:55 +02:00
|
|
|
func (s *DefaultServer) DnsIP() string {
|
2023-07-14 21:56:22 +02:00
|
|
|
return s.service.RuntimeIP()
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stop stops the server
|
|
|
|
func (s *DefaultServer) Stop() {
|
|
|
|
s.mux.Lock()
|
|
|
|
defer s.mux.Unlock()
|
|
|
|
s.ctxCancel()
|
|
|
|
|
2023-06-20 20:33:26 +02:00
|
|
|
if s.hostManager != nil {
|
|
|
|
err := s.hostManager.restoreHostDNS()
|
|
|
|
if err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
}
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
s.service.Stop()
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
// OnUpdatedHostDNSServer update the DNS servers addresses for root zones
|
|
|
|
// It will be applied if the mgm server do not enforce DNS settings for root zone
|
|
|
|
func (s *DefaultServer) OnUpdatedHostDNSServer(hostsDnsList []string) {
|
|
|
|
s.hostsDnsListLock.Lock()
|
|
|
|
defer s.hostsDnsListLock.Unlock()
|
2023-06-12 14:43:55 +02:00
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
s.hostsDnsList = hostsDnsList
|
|
|
|
_, ok := s.dnsMuxMap[nbdns.RootZone]
|
|
|
|
if ok {
|
|
|
|
log.Debugf("on new host DNS config but skip to apply it")
|
|
|
|
return
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
2023-07-14 21:56:22 +02:00
|
|
|
log.Debugf("update host DNS settings: %+v", hostsDnsList)
|
|
|
|
s.addHostRootZone()
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateDNSServer processes an update received from the management service
|
|
|
|
func (s *DefaultServer) UpdateDNSServer(serial uint64, update nbdns.Config) error {
|
|
|
|
select {
|
|
|
|
case <-s.ctx.Done():
|
|
|
|
log.Infof("not updating DNS server as context is closed")
|
|
|
|
return s.ctx.Err()
|
|
|
|
default:
|
|
|
|
if serial < s.updateSerial {
|
|
|
|
return fmt.Errorf("not applying dns update, error: "+
|
|
|
|
"network update is %d behind the last applied update", s.updateSerial-serial)
|
|
|
|
}
|
|
|
|
s.mux.Lock()
|
|
|
|
defer s.mux.Unlock()
|
|
|
|
|
2023-06-15 12:25:18 +02:00
|
|
|
if s.hostManager == nil {
|
|
|
|
return fmt.Errorf("dns service is not initialized yet")
|
|
|
|
}
|
|
|
|
|
2023-06-12 14:43:55 +02:00
|
|
|
hash, err := hashstructure.Hash(update, hashstructure.FormatV2, &hashstructure.HashOptions{
|
|
|
|
ZeroNil: true,
|
|
|
|
IgnoreZeroValue: true,
|
|
|
|
SlicesAsSets: true,
|
|
|
|
UseStringer: true,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("unable to hash the dns configuration update, got error: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if s.previousConfigHash == hash {
|
|
|
|
log.Debugf("not applying the dns configuration update as there is nothing new")
|
|
|
|
s.updateSerial = serial
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := s.applyConfiguration(update); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
s.updateSerial = serial
|
|
|
|
s.previousConfigHash = hash
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DefaultServer) applyConfiguration(update nbdns.Config) error {
|
|
|
|
// is the service should be disabled, we stop the listener or fake resolver
|
|
|
|
// and proceed with a regular update to clean up the handlers and records
|
2023-07-14 21:56:22 +02:00
|
|
|
if update.ServiceEnable {
|
|
|
|
_ = s.service.Listen()
|
|
|
|
} else if !s.permanent {
|
|
|
|
s.service.Stop()
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
localMuxUpdates, localRecords, err := s.buildLocalHandlerUpdate(update.CustomZones)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("not applying dns update, error: %v", err)
|
|
|
|
}
|
|
|
|
upstreamMuxUpdates, err := s.buildUpstreamHandlerUpdate(update.NameServerGroups)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("not applying dns update, error: %v", err)
|
|
|
|
}
|
|
|
|
muxUpdates := append(localMuxUpdates, upstreamMuxUpdates...)
|
|
|
|
|
|
|
|
s.updateMux(muxUpdates)
|
|
|
|
s.updateLocalResolver(localRecords)
|
2023-07-14 21:56:22 +02:00
|
|
|
s.currentConfig = dnsConfigToHostDNSConfig(update, s.service.RuntimeIP(), s.service.RuntimePort())
|
2023-06-12 14:43:55 +02:00
|
|
|
|
|
|
|
hostUpdate := s.currentConfig
|
2023-07-14 21:56:22 +02:00
|
|
|
if s.service.RuntimePort() != defaultPort && !s.hostManager.supportCustomPort() {
|
2023-06-12 14:43:55 +02:00
|
|
|
log.Warnf("the DNS manager of this peer doesn't support custom port. Disabling primary DNS setup. " +
|
2023-08-17 12:27:04 +02:00
|
|
|
"Learn more at: https://docs.netbird.io/how-to/manage-dns-in-your-network#local-resolver")
|
2023-06-12 14:43:55 +02:00
|
|
|
hostUpdate.routeAll = false
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = s.hostManager.applyDNSConfig(hostUpdate); err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DefaultServer) buildLocalHandlerUpdate(customZones []nbdns.CustomZone) ([]muxUpdate, map[string]nbdns.SimpleRecord, error) {
|
|
|
|
var muxUpdates []muxUpdate
|
|
|
|
localRecords := make(map[string]nbdns.SimpleRecord, 0)
|
|
|
|
|
|
|
|
for _, customZone := range customZones {
|
|
|
|
|
|
|
|
if len(customZone.Records) == 0 {
|
|
|
|
return nil, nil, fmt.Errorf("received an empty list of records")
|
|
|
|
}
|
|
|
|
|
|
|
|
muxUpdates = append(muxUpdates, muxUpdate{
|
|
|
|
domain: customZone.Domain,
|
|
|
|
handler: s.localResolver,
|
|
|
|
})
|
|
|
|
|
|
|
|
for _, record := range customZone.Records {
|
|
|
|
var class uint16 = dns.ClassINET
|
|
|
|
if record.Class != nbdns.DefaultClass {
|
|
|
|
return nil, nil, fmt.Errorf("received an invalid class type: %s", record.Class)
|
|
|
|
}
|
|
|
|
key := buildRecordKey(record.Name, class, uint16(record.Type))
|
|
|
|
localRecords[key] = record
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return muxUpdates, localRecords, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DefaultServer) buildUpstreamHandlerUpdate(nameServerGroups []*nbdns.NameServerGroup) ([]muxUpdate, error) {
|
|
|
|
|
|
|
|
var muxUpdates []muxUpdate
|
|
|
|
for _, nsGroup := range nameServerGroups {
|
|
|
|
if len(nsGroup.NameServers) == 0 {
|
|
|
|
log.Warn("received a nameserver group with empty nameserver list")
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
handler := newUpstreamResolver(s.ctx)
|
|
|
|
for _, ns := range nsGroup.NameServers {
|
|
|
|
if ns.NSType != nbdns.UDPNameServerType {
|
2023-11-01 17:11:16 +01:00
|
|
|
log.Warnf("skipping nameserver %s with type %s, this peer supports only %s",
|
2023-06-12 14:43:55 +02:00
|
|
|
ns.IP.String(), ns.NSType.String(), nbdns.UDPNameServerType.String())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
handler.upstreamServers = append(handler.upstreamServers, getNSHostPort(ns))
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(handler.upstreamServers) == 0 {
|
|
|
|
handler.stop()
|
|
|
|
log.Errorf("received a nameserver group with an invalid nameserver list")
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// when upstream fails to resolve domain several times over all it servers
|
|
|
|
// it will calls this hook to exclude self from the configuration and
|
|
|
|
// reapply DNS settings, but it not touch the original configuration and serial number
|
|
|
|
// because it is temporal deactivation until next try
|
|
|
|
//
|
2023-11-01 17:11:16 +01:00
|
|
|
// after some period defined by upstream it tries to reactivate self by calling this hook
|
2023-06-12 14:43:55 +02:00
|
|
|
// everything we need here is just to re-apply current configuration because it already
|
|
|
|
// contains this upstream settings (temporal deactivation not removed it)
|
|
|
|
handler.deactivate, handler.reactivate = s.upstreamCallbacks(nsGroup, handler)
|
|
|
|
|
|
|
|
if nsGroup.Primary {
|
|
|
|
muxUpdates = append(muxUpdates, muxUpdate{
|
|
|
|
domain: nbdns.RootZone,
|
|
|
|
handler: handler,
|
|
|
|
})
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(nsGroup.Domains) == 0 {
|
|
|
|
handler.stop()
|
|
|
|
return nil, fmt.Errorf("received a non primary nameserver group with an empty domain list")
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, domain := range nsGroup.Domains {
|
|
|
|
if domain == "" {
|
|
|
|
handler.stop()
|
|
|
|
return nil, fmt.Errorf("received a nameserver group with an empty domain element")
|
|
|
|
}
|
|
|
|
muxUpdates = append(muxUpdates, muxUpdate{
|
|
|
|
domain: domain,
|
|
|
|
handler: handler,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return muxUpdates, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DefaultServer) updateMux(muxUpdates []muxUpdate) {
|
|
|
|
muxUpdateMap := make(registeredHandlerMap)
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
var isContainRootUpdate bool
|
|
|
|
|
2023-06-12 14:43:55 +02:00
|
|
|
for _, update := range muxUpdates {
|
2023-07-14 21:56:22 +02:00
|
|
|
s.service.RegisterMux(update.domain, update.handler)
|
2023-06-12 14:43:55 +02:00
|
|
|
muxUpdateMap[update.domain] = update.handler
|
|
|
|
if existingHandler, ok := s.dnsMuxMap[update.domain]; ok {
|
|
|
|
existingHandler.stop()
|
|
|
|
}
|
2023-07-14 21:56:22 +02:00
|
|
|
|
|
|
|
if update.domain == nbdns.RootZone {
|
|
|
|
isContainRootUpdate = true
|
|
|
|
}
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for key, existingHandler := range s.dnsMuxMap {
|
|
|
|
_, found := muxUpdateMap[key]
|
|
|
|
if !found {
|
2023-07-14 21:56:22 +02:00
|
|
|
if !isContainRootUpdate && key == nbdns.RootZone {
|
|
|
|
s.hostsDnsListLock.Lock()
|
|
|
|
s.addHostRootZone()
|
|
|
|
s.hostsDnsListLock.Unlock()
|
|
|
|
existingHandler.stop()
|
|
|
|
} else {
|
|
|
|
existingHandler.stop()
|
|
|
|
s.service.DeregisterMux(key)
|
|
|
|
}
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s.dnsMuxMap = muxUpdateMap
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DefaultServer) updateLocalResolver(update map[string]nbdns.SimpleRecord) {
|
|
|
|
for key := range s.localResolver.registeredMap {
|
|
|
|
_, found := update[key]
|
|
|
|
if !found {
|
|
|
|
s.localResolver.deleteRecord(key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updatedMap := make(registrationMap)
|
|
|
|
for key, record := range update {
|
|
|
|
err := s.localResolver.registerRecord(record)
|
|
|
|
if err != nil {
|
|
|
|
log.Warnf("got an error while registering the record (%s), error: %v", record.String(), err)
|
|
|
|
}
|
|
|
|
updatedMap[key] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
s.localResolver.registeredMap = updatedMap
|
|
|
|
}
|
|
|
|
|
|
|
|
func getNSHostPort(ns nbdns.NameServer) string {
|
|
|
|
return fmt.Sprintf("%s:%d", ns.IP.String(), ns.Port)
|
|
|
|
}
|
|
|
|
|
|
|
|
// upstreamCallbacks returns two functions, the first one is used to deactivate
|
|
|
|
// the upstream resolver from the configuration, the second one is used to
|
|
|
|
// reactivate it. Not allowed to call reactivate before deactivate.
|
|
|
|
func (s *DefaultServer) upstreamCallbacks(
|
|
|
|
nsGroup *nbdns.NameServerGroup,
|
|
|
|
handler dns.Handler,
|
|
|
|
) (deactivate func(), reactivate func()) {
|
|
|
|
var removeIndex map[string]int
|
|
|
|
deactivate = func() {
|
|
|
|
s.mux.Lock()
|
|
|
|
defer s.mux.Unlock()
|
|
|
|
|
|
|
|
l := log.WithField("nameservers", nsGroup.NameServers)
|
|
|
|
l.Info("temporary deactivate nameservers group due timeout")
|
|
|
|
|
|
|
|
removeIndex = make(map[string]int)
|
|
|
|
for _, domain := range nsGroup.Domains {
|
|
|
|
removeIndex[domain] = -1
|
|
|
|
}
|
|
|
|
if nsGroup.Primary {
|
|
|
|
removeIndex[nbdns.RootZone] = -1
|
|
|
|
s.currentConfig.routeAll = false
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, item := range s.currentConfig.domains {
|
|
|
|
if _, found := removeIndex[item.domain]; found {
|
|
|
|
s.currentConfig.domains[i].disabled = true
|
2023-07-14 21:56:22 +02:00
|
|
|
s.service.DeregisterMux(item.domain)
|
2023-06-12 14:43:55 +02:00
|
|
|
removeIndex[item.domain] = i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := s.hostManager.applyDNSConfig(s.currentConfig); err != nil {
|
|
|
|
l.WithError(err).Error("fail to apply nameserver deactivation on the host")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reactivate = func() {
|
|
|
|
s.mux.Lock()
|
|
|
|
defer s.mux.Unlock()
|
|
|
|
|
|
|
|
for domain, i := range removeIndex {
|
|
|
|
if i == -1 || i >= len(s.currentConfig.domains) || s.currentConfig.domains[i].domain != domain {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
s.currentConfig.domains[i].disabled = false
|
2023-07-14 21:56:22 +02:00
|
|
|
s.service.RegisterMux(domain, handler)
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
l := log.WithField("nameservers", nsGroup.NameServers)
|
|
|
|
l.Debug("reactivate temporary disabled nameserver group")
|
|
|
|
|
|
|
|
if nsGroup.Primary {
|
|
|
|
s.currentConfig.routeAll = true
|
|
|
|
}
|
|
|
|
if err := s.hostManager.applyDNSConfig(s.currentConfig); err != nil {
|
|
|
|
l.WithError(err).Error("reactivate temporary disabled nameserver group, DNS update apply")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-07-14 21:56:22 +02:00
|
|
|
func (s *DefaultServer) addHostRootZone() {
|
|
|
|
handler := newUpstreamResolver(s.ctx)
|
|
|
|
handler.upstreamServers = make([]string, len(s.hostsDnsList))
|
|
|
|
for n, ua := range s.hostsDnsList {
|
|
|
|
handler.upstreamServers[n] = fmt.Sprintf("%s:53", ua)
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|
2023-07-14 21:56:22 +02:00
|
|
|
handler.deactivate = func() {}
|
|
|
|
handler.reactivate = func() {}
|
|
|
|
s.service.RegisterMux(nbdns.RootZone, handler)
|
2023-06-12 14:43:55 +02:00
|
|
|
}
|