Pull request 2354: AGDNS-2690-global-context-tls
Merge in DNS/adguard-home from AGDNS-2690-global-context-tls to master Squashed commit of the following: commit ae1d9e6f3f3b8abefbc5e776eb256577f7fbbb0f Merge: 6f30f488abf9be98c7Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 18:15:24 2025 +0300 Merge branch 'master' into AGDNS-2690-global-context-tls commit 6f30f488aa2305e518000dc6c1028ede83bf1cc6 Merge: baa187ab066fba942cAuthor: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 15:08:47 2025 +0300 Merge branch 'master' into AGDNS-2690-global-context-tls commit baa187ab0b6db7f41e49dece7b4d0430409e7cae Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 15:08:39 2025 +0300 home: imp docs commit 96a09389c5049a84bb30ed285cc5e1df9aaa438f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 6 20:15:05 2025 +0300 home: imp docs commit 1cd007707af4a7a5160c8fe21b20b84543d59e5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Mar 6 18:54:07 2025 +0300 home: imp docs commit ad3d2b6616c2c3aba566a2158ffc597e5802929f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Mar 4 19:38:45 2025 +0300 home: global context tls
This commit is contained in:
@@ -39,16 +39,22 @@ const (
|
||||
|
||||
// Called by other modules when configuration is changed
|
||||
func onConfigModified() {
|
||||
err := config.write()
|
||||
err := config.write(globalContext.tls)
|
||||
if err != nil {
|
||||
log.Error("writing config: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// initDNS updates all the fields of the [globalContext] needed to initialize the DNS
|
||||
// server and initializes it at last. It also must not be called unless
|
||||
// [config] and [globalContext] are initialized. baseLogger must not be nil.
|
||||
func initDNS(baseLogger *slog.Logger, statsDir, querylogDir string) (err error) {
|
||||
// initDNS updates all the fields of the [globalContext] needed to initialize
|
||||
// the DNS server and initializes it at last. It also must not be called unless
|
||||
// [config] and [globalContext] are initialized. baseLogger and tlsMgr must not
|
||||
// be nil.
|
||||
func initDNS(
|
||||
baseLogger *slog.Logger,
|
||||
tlsMgr *tlsManager,
|
||||
statsDir string,
|
||||
querylogDir string,
|
||||
) (err error) {
|
||||
anonymizer := config.anonymizer()
|
||||
|
||||
statsConf := stats.Config{
|
||||
@@ -104,7 +110,7 @@ func initDNS(baseLogger *slog.Logger, statsDir, querylogDir string) (err error)
|
||||
}
|
||||
|
||||
tlsConf := &tlsConfigSettings{}
|
||||
globalContext.tls.WriteDiskConfig(tlsConf)
|
||||
tlsMgr.WriteDiskConfig(tlsConf)
|
||||
|
||||
return initDNSServer(
|
||||
globalContext.filters,
|
||||
@@ -357,16 +363,18 @@ func newDNSCryptConfig(
|
||||
}, nil
|
||||
}
|
||||
|
||||
// dnsEncryption contains different types of TLS encryption addresses.
|
||||
type dnsEncryption struct {
|
||||
https string
|
||||
tls string
|
||||
quic string
|
||||
}
|
||||
|
||||
func getDNSEncryption() (de dnsEncryption) {
|
||||
// getDNSEncryption returns the TLS encryption addresses that AdGuard Home
|
||||
// listens on. tlsMgr must not be nil.
|
||||
func getDNSEncryption(tlsMgr *tlsManager) (de dnsEncryption) {
|
||||
tlsConf := tlsConfigSettings{}
|
||||
|
||||
globalContext.tls.WriteDiskConfig(&tlsConf)
|
||||
tlsMgr.WriteDiskConfig(&tlsConf)
|
||||
|
||||
if !tlsConf.Enabled || len(tlsConf.ServerName) == 0 {
|
||||
return dnsEncryption{}
|
||||
@@ -487,9 +495,11 @@ func startDNSServer() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func reconfigureDNSServer() (err error) {
|
||||
// reconfigureDNSServer updates the DNS server configuration using the provided
|
||||
// TLS settings. tlsMgr must not be nil.
|
||||
func reconfigureDNSServer(tlsMgr *tlsManager) (err error) {
|
||||
tlsConf := &tlsConfigSettings{}
|
||||
globalContext.tls.WriteDiskConfig(tlsConf)
|
||||
tlsMgr.WriteDiskConfig(tlsConf)
|
||||
|
||||
newConf, err := newServerConfig(
|
||||
&config.DNS,
|
||||
|
||||
Reference in New Issue
Block a user