mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-22 21:39:08 +02:00
The daemon SetConfig only persisted the lazy connection flag to the profile config; the running engine was untouched, so a UI/CLI change took effect only after a down/up or daemon restart. Wire SetConfig to push the change into the running engine via a new ConnMgr.SetLocalLazyConn, which sets enabledLocally like an env/CLI flag so a later management sync cannot override it, and starts or stops the lazy manager in place.
20 lines
524 B
Go
20 lines
524 B
Go
package internal
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
// SetLazyConnEnabled applies a local lazy connection override to the running
|
|
// engine. It pins the setting like an env/CLI flag, so a later management sync
|
|
// cannot override it. syncMsgMux guards ConnMgr, which is not thread-safe.
|
|
func (e *Engine) SetLazyConnEnabled(enabled bool) error {
|
|
e.syncMsgMux.Lock()
|
|
defer e.syncMsgMux.Unlock()
|
|
|
|
if e.connMgr == nil {
|
|
return errors.New("connection manager is not initialised")
|
|
}
|
|
|
|
return e.connMgr.SetLocalLazyConn(e.ctx, enabled)
|
|
}
|