Skip to content

Commit

Permalink
Merge branch 'master' into 7069-fix-blocked-services
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Jun 18, 2024
2 parents c244075 + 66877c9 commit 87f06b8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ NOTE: Add new changes BELOW THIS COMMENT.

- 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/aghnet/hostscontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ func (hc *HostsContainer) handleEvents() {

defer close(hc.updates)

ok, eventsCh := true, hc.watcher.Events()
eventsCh := hc.watcher.Events()
ok := eventsCh != nil
for ok {
select {
case _, ok = <-eventsCh:
Expand Down
31 changes: 31 additions & 0 deletions internal/aghos/fswatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,34 @@ func (w *osWatcher) handleErrors() {
log.Error("%s: %s", osWatcherPref, err)
}
}

// EmptyFSWatcher is a no-op implementation of the [FSWatcher] interface. It
// may be used on systems not supporting filesystem events.
type EmptyFSWatcher struct{}

// type check
var _ FSWatcher = EmptyFSWatcher{}

// Start implements the [FSWatcher] interface for EmptyFSWatcher. It always
// returns nil error.
func (EmptyFSWatcher) Start() (err error) {
return nil
}

// Close implements the [FSWatcher] interface for EmptyFSWatcher. It always
// returns nil error.
func (EmptyFSWatcher) Close() (err error) {
return nil
}

// Events implements the [FSWatcher] interface for EmptyFSWatcher. It always
// returns nil channel.
func (EmptyFSWatcher) Events() (e <-chan event) {
return nil
}

// Add implements the [FSWatcher] interface for EmptyFSWatcher. It always
// returns nil error.
func (EmptyFSWatcher) Add(_ string) (err error) {
return nil
}
4 changes: 3 additions & 1 deletion internal/home/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ func configureOS(conf *configuration) (err error) {
func setupHostsContainer() (err error) {
hostsWatcher, err := aghos.NewOSWritesWatcher()
if err != nil {
return fmt.Errorf("initing hosts watcher: %w", err)
log.Info("WARNING: initializing filesystem watcher: %s; not watching for changes", err)

hostsWatcher = aghos.EmptyFSWatcher{}
}

paths, err := hostsfile.DefaultHostsPaths()
Expand Down

0 comments on commit 87f06b8

Please sign in to comment.