Files
netbird/client/ui/tray_features.go
Zoltan Papp 47ecc41bf4 Merge main into ui-refactor; port MDM support to the Wails UI
Integrates main's MDM configuration-profile feature and adapts it to the
Wails UI (this branch had already replaced the Fyne UI).

Conflict resolution:
- go.mod/go.sum: take main's deps; howett.net/plist pinned to v1.0.2-... (tidy)
- client/proto/daemon.pb.go: regenerated from the merged daemon.proto
- client/internal/peer/status.go: union of ipToKey (main) + sessionExpiresAt (HEAD)
- client/server/server.go: main's intent/liveness model (connectionGoroutineRunning,
  clientRunning no longer cleared by the goroutine) + empty-PSK guard
- client/ui/client_ui.go, client/ui/profile.go: removed (dead Fyne UI)

MDM port (backend + tray):
- services/settings.go: expose MDMManagedFields plus a managedFields map keyed
  by Config field names so the settings form can gate a control without
  translating mdm.Key* names
- tray: gate Profiles / Exit Node menus on DisableProfiles / DisableNetworks via
  GetFeatures, refreshed on the config_changed system event (replaces the legacy
  2s poll); localized MDM policy-applied toast in all shipped locales
- client/proto/metadata.go: shared constants for the config_changed /
  policy_applied event markers

PreSharedKey: GetConfig now returns preSharedKeySet (bool) instead of the masked
value; the settings form provides its own placeholder and sends a new key only
when the user types one.
2026-06-12 15:27:23 +02:00

48 lines
1.8 KiB
Go

//go:build !android && !ios && !freebsd && !js
package main
import (
"context"
log "github.com/sirupsen/logrus"
)
// refreshFeatures pulls the daemon's operator-disabled UI surfaces
// (DisableProfiles / DisableNetworks) and re-applies the tray menu gating.
// Called once at startup (ApplicationStarted) and on every config_changed
// system event — the daemon re-applies its MDM policy on each engine spawn
// and emits that event, so this is the tray's signal to re-sync the kill
// switches. It replaces the legacy Fyne UI's 2s GetFeatures poll.
func (t *Tray) refreshFeatures() {
features, err := t.svc.Settings.GetFeatures(context.Background())
if err != nil {
log.Debugf("get features: %v", err)
return
}
t.featureMu.Lock()
changed := t.disableProfiles != features.DisableProfiles ||
t.disableNetworks != features.DisableNetworks
t.disableProfiles = features.DisableProfiles
t.disableNetworks = features.DisableNetworks
t.featureMu.Unlock()
// Repaint only when a flag actually flipped: relayoutMenu rebuilds the
// whole menu tree, so a no-op refresh (the common case) must not churn
// it. relayoutMenu and fillProfileSubmenu read the cached flags via
// featuresDisabled, so the new state applies regardless of which relayout
// (this one, a status push, or a profile reload) runs last.
if changed {
t.relayoutMenu()
}
}
// featuresDisabled returns the cached DisableProfiles / DisableNetworks kill
// switches under featureMu. Read by relayoutMenu, refreshMenuItemsForStatus,
// and fillProfileSubmenu to grey out the Profiles and Exit Node menus when
// the operator (or an MDM policy) disabled those surfaces server-side.
func (t *Tray) featuresDisabled() (profiles, networks bool) {
t.featureMu.Lock()
defer t.featureMu.Unlock()
return t.disableProfiles, t.disableNetworks
}