From 5f696da9dcbb4dfa93eac7cf658924f230353916 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Fri, 8 Sep 2023 15:04:25 +0300 Subject: [PATCH] Pull request 2005: 6181-safebrowsing-default Updates #6181. Squashed commit of the following: commit 3c4d0fe0750823c81548c2e81988ec27c718028f Author: Ainar Garipov Date: Fri Sep 8 14:23:13 2023 +0300 home: fix default safe browsing, parental --- CHANGELOG.md | 7 +++++++ internal/home/config.go | 9 +++++++++ internal/home/home.go | 25 ++++++++++++++++++------- scripts/translations/main.go | 2 +- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8403683..b23cf6a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,13 @@ See also the [v0.107.38 GitHub milestone][ms-v0.107.38]. NOTE: Add new changes BELOW THIS COMMENT. --> +### Fixed + +- Empty or default Safe Browsing and Parental Control settings ([#6181]). +- Various UI issues. + +[#6181]: https://github.com/AdguardTeam/AdGuardHome/issues/6181 + diff --git a/internal/home/config.go b/internal/home/config.go index 0be84753..7a70b893 100644 --- a/internal/home/config.go +++ b/internal/home/config.go @@ -282,6 +282,12 @@ type statsConfig struct { Enabled bool `yaml:"enabled"` } +// Default block host constants. +const ( + defaultSafeBrowsingBlockHost = "standard-block.dns.adguard.com" + defaultParentalBlockHost = "family-block.dns.adguard.com" +) + // config is the global configuration structure. // // TODO(a.garipov, e.burkov): This global is awful and must be removed. @@ -389,6 +395,9 @@ var config = &configuration{ Schedule: schedule.EmptyWeekly(), IDs: []string{}, }, + + ParentalBlockHost: defaultParentalBlockHost, + SafeBrowsingBlockHost: defaultSafeBrowsingBlockHost, }, DHCP: &dhcpd.ServerConfig{ LocalDomainName: "lan", diff --git a/internal/home/home.go b/internal/home/home.go index eae9422a..613e6429 100644 --- a/internal/home/home.go +++ b/internal/home/home.go @@ -359,9 +359,6 @@ func setupDNSFilteringConf(conf *filtering.Config) (err error) { pcService = "parental control" defaultParentalServer = `https://family.adguard-dns.com/dns-query` pcTXTSuffix = `pc.dns.adguard.com.` - - defaultSafeBrowsingBlockHost = "standard-block.dns.adguard.com" - defaultParentalBlockHost = "family-block.dns.adguard.com" ) conf.EtcHosts = Context.etcHosts @@ -398,8 +395,15 @@ func setupDNSFilteringConf(conf *filtering.Config) (err error) { CacheSize: conf.SafeBrowsingCacheSize, }) - if conf.SafeBrowsingBlockHost != "" { - conf.SafeBrowsingBlockHost = defaultSafeBrowsingBlockHost + // Protect against invalid configuration, see #6181. + // + // TODO(a.garipov): Validate against an empty host instead of setting it to + // default. + if conf.SafeBrowsingBlockHost == "" { + host := defaultSafeBrowsingBlockHost + log.Info("%s: warning: empty blocking host; using default: %q", sbService, host) + + conf.SafeBrowsingBlockHost = host } parUps, err := upstream.AddressToUpstream(defaultParentalServer, upsOpts) @@ -415,8 +419,15 @@ func setupDNSFilteringConf(conf *filtering.Config) (err error) { CacheSize: conf.ParentalCacheSize, }) - if conf.ParentalBlockHost != "" { - conf.ParentalBlockHost = defaultParentalBlockHost + // Protect against invalid configuration, see #6181. + // + // TODO(a.garipov): Validate against an empty host instead of setting it to + // default. + if conf.ParentalBlockHost == "" { + host := defaultParentalBlockHost + log.Info("%s: warning: empty blocking host; using default: %q", pcService, host) + + conf.ParentalBlockHost = host } conf.SafeSearchConf.CustomResolver = safeSearchResolver{} diff --git a/scripts/translations/main.go b/scripts/translations/main.go index 800c36ee..cff6d03c 100644 --- a/scripts/translations/main.go +++ b/scripts/translations/main.go @@ -30,7 +30,7 @@ const ( twoskyURI = "https://twosky.int.agrd.dev/api/v1" readLimit = 1 * 1024 * 1024 - uploadTimeout = 10 * time.Second + uploadTimeout = 20 * time.Second ) // blockerLangCodes is the codes of languages which need to be fully translated.