From 795f3ddf93efed893a2ff467e4afbe252d3c6417 Mon Sep 17 00:00:00 2001 From: ThinkChaos Date: Mon, 15 May 2023 10:24:07 -0400 Subject: [PATCH] fix: configuration for FQDN only resolver (#1025) --- config/config.go | 2 +- config/config_test.go | 6 ++++++ docs/config.yml | 6 ++++++ docs/configuration.md | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 455757ed..64568b2c 100644 --- a/config/config.go +++ b/config/config.go @@ -178,7 +178,7 @@ type Config struct { KeyFile string `yaml:"keyFile"` BootstrapDNS BootstrapDNSConfig `yaml:"bootstrapDns"` HostsFile HostsFileConfig `yaml:"hostsFile"` - FqdnOnly FqdnOnlyConfig `yaml:",inline"` + FqdnOnly FqdnOnlyConfig `yaml:"fqdnOnly"` Filtering FilteringConfig `yaml:"filtering"` Ede EdeConfig `yaml:"ede"` // Deprecated diff --git a/config/config_test.go b/config/config_test.go index 7eea1e66..1ca8c432 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -550,6 +550,7 @@ func defaultTestFileConfig() { Expect(config.Blocking.BlockTTL).Should(Equal(Duration(time.Minute))) Expect(config.Blocking.RefreshPeriod).Should(Equal(Duration(2 * time.Hour))) Expect(config.Filtering.QueryTypes).Should(HaveLen(2)) + Expect(config.FqdnOnly.Enable).Should(BeTrue()) Expect(config.Caching.MaxCachingTime.IsZero()).Should(BeTrue()) Expect(config.Caching.MinCachingTime.IsZero()).Should(BeTrue()) @@ -580,6 +581,8 @@ func writeConfigYml(tmpDir *helpertest.TmpFolder) *helpertest.TmpFile { " queryTypes:", " - AAAA", " - A", + "fqdnOnly:", + " enable: true", "blocking:", " blackLists:", " ads:", @@ -617,6 +620,7 @@ func writeConfigYml(tmpDir *helpertest.TmpFolder) *helpertest.TmpFile { "startVerifyUpstream: false") } +//nolint:funlen func writeConfigDir(tmpDir *helpertest.TmpFolder) error { f1 := tmpDir.CreateStringFile("config1.yaml", "upstream:", @@ -668,6 +672,8 @@ func writeConfigDir(tmpDir *helpertest.TmpFolder) error { " singleNameOrder:", " - 2", " - 1", + "fqdnOnly:", + " enable: true", "queryLog:", " type: csv-client", " target: /opt/log", diff --git a/docs/config.yml b/docs/config.yml index 7bb0d6ad..89bb6751 100644 --- a/docs/config.yml +++ b/docs/config.yml @@ -217,6 +217,7 @@ minTlsServeVersion: 1.3 # if https port > 0: path to cert and key file for SSL encryption. if not set, self-signed certificate will be generated #certFile: server.crt #keyFile: server.key + # optional: use these DNS servers to resolve blacklist urls and upstream DNS servers. It is useful if no system DNS resolver is configured, and/or to encrypt the bootstrap queries. bootstrapDns: - tcp+udp:1.1.1.1 @@ -230,6 +231,11 @@ filtering: queryTypes: - AAAA +# optional: return NXDOMAIN for queries that are not FQDNs. +fqdnOnly: + # default: false + enable: true + # optional: if path defined, use this file for query resolution (A, AAAA and rDNS). Default: empty hostsFile: # optional: Path to hosts file (e.g. /etc/hosts on Linux) diff --git a/docs/configuration.md b/docs/configuration.md index c6312716..37ab1682 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -195,7 +195,8 @@ Please be aware that by enabling it your hostname resolution will break unless e !!! example ```yaml - fqdnOnly: true + fqdnOnly: + enable: true ``` ## Custom DNS