mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-03 00:25:37 +02:00
[client] Fix a panic on shutdown if dns host manager failed to initialize (#3182)
This commit is contained in:
parent
b9efda3ce8
commit
b34887a920
@ -48,11 +48,17 @@ type restoreHostManager interface {
|
|||||||
func newHostManager(wgInterface string) (hostManager, error) {
|
func newHostManager(wgInterface string) (hostManager, error) {
|
||||||
osManager, err := getOSDNSManagerType()
|
osManager, err := getOSDNSManagerType()
|
||||||
if err != nil {
|
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)
|
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) {
|
func newHostManagerFromType(wgInterface string, osManager osManagerType) (restoreHostManager, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user