Skip to content

Commit

Permalink
[client] Fix a panic on shutdown if dns host manager failed to initia…
Browse files Browse the repository at this point in the history
…lize (#3182)
  • Loading branch information
lixmal authored Jan 15, 2025
1 parent b9efda3 commit b34887a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions client/internal/dns/host_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ type restoreHostManager interface {
func newHostManager(wgInterface string) (hostManager, error) {
osManager, err := getOSDNSManagerType()
if err != nil {
return nil, err
return nil, fmt.Errorf("get os dns manager type: %w", err)
}

log.Infof("System DNS manager discovered: %s", osManager)
return newHostManagerFromType(wgInterface, osManager)
mgr, err := newHostManagerFromType(wgInterface, osManager)
// need to explicitly return nil mgr on error to avoid returning a non-nil interface containing a nil value
if err != nil {
return nil, fmt.Errorf("create host manager: %w", err)
}

return mgr, nil
}

func newHostManagerFromType(wgInterface string, osManager osManagerType) (restoreHostManager, error) {
Expand Down

0 comments on commit b34887a

Please sign in to comment.