Merge: - install: recover from error on DNS server start

Close #1293

Squashed commit of the following:

commit 0981754c5c2c67f2567ee4af0d9ab24377c53413
Merge: ef81f2c8 a6d75118
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Thu Jan 16 14:19:20 2020 +0300

    Merge remote-tracking branch 'origin/master' into 1293-install

commit ef81f2c886f3bfcff4e4352d7ecea6642be7d8e1
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Mon Dec 30 18:32:11 2019 +0300

    linter

commit 9e205be53d9de25bd2ad63398644e14b09f95238
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Mon Dec 30 17:22:17 2019 +0300

    - install: recover from error on DNS server start

    Close all modules properly
    Don't register HTTP handlers twice
This commit is contained in:
Simon Zolin
2020-01-16 14:25:40 +03:00
parent a6d7511806
commit 6563886b49
8 changed files with 61 additions and 24 deletions

View File

@@ -33,6 +33,8 @@ var defaultDNS = []string{
}
var defaultBootstrap = []string{"9.9.9.9", "149.112.112.112"}
var webRegistered bool
// Server is the main way to start a DNS server.
//
// Example:
@@ -54,8 +56,7 @@ type Server struct {
// We don't Start() it and so no listen port is required.
internalProxy *proxy.Proxy
webRegistered bool
isRunning bool
isRunning bool
sync.RWMutex
conf ServerConfig
@@ -318,8 +319,8 @@ func (s *Server) Prepare(config *ServerConfig) error {
log.Fatal("len(proxyConfig.Upstreams) == 0")
}
if !s.webRegistered && s.conf.HTTPRegister != nil {
s.webRegistered = true
if !webRegistered && s.conf.HTTPRegister != nil {
webRegistered = true
s.registerHandlers()
}