Skip to content

Commit

Permalink
Pull request 2235: 7069-fix-blocked-services
Browse files Browse the repository at this point in the history
Updates AdguardTeam#7069.

Squashed commit of the following:

commit 0f87493
Merge: 87f06b8 28a6c24
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Jun 18 14:09:18 2024 +0300

    Merge branch 'master' into 7069-fix-blocked-services

commit 87f06b8
Merge: c244075 66877c9
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Jun 18 13:47:28 2024 +0300

    Merge branch 'master' into 7069-fix-blocked-services

commit c244075
Merge: 17a9c14 1c82be2
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Mon Jun 17 18:42:48 2024 +0300

    Merge branch 'master' into 7069-fix-blocked-services

commit 17a9c14
Merge: 11160bc bed86d5
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Jun 11 13:41:00 2024 +0300

    Merge branch 'master' into 7069-fix-blocked-services

commit 11160bc
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Jun 11 13:36:56 2024 +0300

    all: imp docs

commit 4912871
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Mon Jun 10 14:03:22 2024 +0300

    home: imp code

commit 0caf8b1
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Mon Jun 10 13:35:54 2024 +0300

    all: upd chlog

commit 46f793b
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Mon Jun 10 13:27:22 2024 +0300

    home: fix blocked services
  • Loading branch information
schzhn committed Jun 18, 2024
1 parent 28a6c24 commit 08d863d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ NOTE: Add new changes BELOW THIS COMMENT.

### Fixed

- Panic caused by missing user-specific blocked services object in configuration
file ([#7069]).
- Tracking `/etc/hosts` file changes causing panics within particular
filesystems on start ([#7076]).

[#7053]: https://github.com/AdguardTeam/AdGuardHome/issues/7053
[#7069]: https://github.com/AdguardTeam/AdGuardHome/issues/7069
[#7076]: https://github.com/AdguardTeam/AdGuardHome/issues/7076

[install-script]: https://github.com/AdguardTeam/AdGuardHome/?tab=readme-ov-file#automated-install-linux-and-mac

Expand Down
3 changes: 2 additions & 1 deletion internal/client/persistent.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ type Persistent struct {

SafeSearch filtering.SafeSearch

// BlockedServices is the configuration of blocked services of a client.
// BlockedServices is the configuration of blocked services of a client. It
// must not be nil after initialization.
BlockedServices *filtering.BlockedServices

Name string
Expand Down
7 changes: 7 additions & 0 deletions internal/home/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
"github.com/AdguardTeam/AdGuardHome/internal/querylog"
"github.com/AdguardTeam/AdGuardHome/internal/schedule"
"github.com/AdguardTeam/AdGuardHome/internal/whois"
"github.com/AdguardTeam/dnsproxy/proxy"
"github.com/AdguardTeam/dnsproxy/upstream"
Expand Down Expand Up @@ -261,6 +262,12 @@ func (o *clientObject) toPersistent(
}
}

if o.BlockedServices == nil {
o.BlockedServices = &filtering.BlockedServices{
Schedule: schedule.EmptyWeekly(),
}
}

err = o.BlockedServices.Validate()
if err != nil {
return nil, fmt.Errorf("init blocked services %q: %w", cli.Name, err)
Expand Down
2 changes: 1 addition & 1 deletion internal/home/clientshttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func copyBlockedServices(
var weekly *schedule.Weekly
if sch != nil {
weekly = sch.Clone()
} else if prev != nil && prev.BlockedServices != nil {
} else if prev != nil {
weekly = prev.BlockedServices.Schedule.Clone()
} else {
weekly = schedule.EmptyWeekly()
Expand Down
2 changes: 1 addition & 1 deletion internal/home/clientshttp_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func newPersistentClient(name string) (c *client.Persistent) {
Name: name,
UID: client.MustNewUID(),
BlockedServices: &filtering.BlockedServices{
Schedule: &schedule.Weekly{},
Schedule: schedule.EmptyWeekly(),
},
}
}
Expand Down

0 comments on commit 08d863d

Please sign in to comment.