Skip to content

Commit

Permalink
Pull request 2005: 6181-safebrowsing-default
Browse files Browse the repository at this point in the history
Updates #6181.

Squashed commit of the following:

commit 3c4d0fe
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Sep 8 14:23:13 2023 +0300

    home: fix default safe browsing, parental
  • Loading branch information
ainar-g committed Sep 8, 2023
1 parent 62da8f4 commit 5f696da
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<!--
NOTE: Add new changes ABOVE THIS COMMENT.
-->
Expand Down
9 changes: 9 additions & 0 deletions internal/home/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -389,6 +395,9 @@ var config = &configuration{
Schedule: schedule.EmptyWeekly(),
IDs: []string{},
},

ParentalBlockHost: defaultParentalBlockHost,
SafeBrowsingBlockHost: defaultSafeBrowsingBlockHost,
},
DHCP: &dhcpd.ServerConfig{
LocalDomainName: "lan",
Expand Down
25 changes: 18 additions & 7 deletions internal/home/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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{}
Expand Down
2 changes: 1 addition & 1 deletion scripts/translations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5f696da

Please sign in to comment.