Pull request: 5044 Close upstreams
Merge in DNS/adguard-home from 5044-close-upstreams to master Closes #5044. Squashed commit of the following: commit e121380ecb32bd2664d47f0968c68509156404c1 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Oct 19 15:54:17 2022 +0300 all: upd proxy again commit ce7fa539a7430a1a197fd45e7988697010c684db Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Oct 19 14:30:46 2022 +0300 home: imp docs, names commit 851c5b8128149941cc469e6192ec9b4b1f92b0b5 Merge: b9ee5d63d2a09e49Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Oct 19 14:21:44 2022 +0300 Merge branch 'master' into 5044-close-upstreams commit b9ee5d6348e696ff0b44dabee601469c545c8bd9 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Oct 19 14:20:15 2022 +0300 all: close upstreams more commit eaca476319dc64e7986e26e67110005938cf1278 Merge: f924bc7a8dba4ecdAuthor: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Oct 18 18:33:53 2022 +0300 Merge branch 'master' into 5044-close-upstreams commit f924bc7a836001f8bb7463de2b5ddaf1be1a53c1 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Oct 18 18:23:54 2022 +0300 all: imp code, docs commit 011fde16aa912fc78e3d6f60375cee73a0d88709 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Oct 18 17:26:40 2022 +0300 all: upd dnsproxy
This commit is contained in:
@@ -518,7 +518,7 @@ func validateBlockingMode(mode BlockingMode, blockingIPv4, blockingIPv6 net.IP)
|
||||
}
|
||||
|
||||
// prepareInternalProxy initializes the DNS proxy that is used for internal DNS
|
||||
// queries, such at client PTR resolving and updater hostname resolving.
|
||||
// queries, such as public clients PTR resolving and updater hostname resolving.
|
||||
func (s *Server) prepareInternalProxy() (err error) {
|
||||
conf := &proxy.Config{
|
||||
CacheEnabled: true,
|
||||
@@ -558,16 +558,37 @@ func (s *Server) Stop() error {
|
||||
return s.stopLocked()
|
||||
}
|
||||
|
||||
// stopLocked stops the DNS server without locking. For internal use only.
|
||||
func (s *Server) stopLocked() error {
|
||||
// stopLocked stops the DNS server without locking. For internal use only.
|
||||
func (s *Server) stopLocked() (err error) {
|
||||
var errs []error
|
||||
|
||||
if s.dnsProxy != nil {
|
||||
err := s.dnsProxy.Stop()
|
||||
err = s.dnsProxy.Stop()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not stop the DNS server properly: %w", err)
|
||||
errs = append(errs, fmt.Errorf("could not stop primary resolvers properly: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
s.isRunning = false
|
||||
if s.internalProxy != nil && s.internalProxy.UpstreamConfig != nil {
|
||||
err = s.internalProxy.UpstreamConfig.Close()
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Errorf("could not stop internal resolvers properly: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
if s.localResolvers != nil && s.localResolvers.UpstreamConfig != nil {
|
||||
err = s.localResolvers.UpstreamConfig.Close()
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Errorf("could not stop local resolvers properly: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return errors.List("stopping DNS server", errs...)
|
||||
} else {
|
||||
s.isRunning = false
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user