mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-26 17:41:30 +02:00
* [client] Add iOS NetBirdSDK profile manager binding Mirror the Android profile manager in the iOS gomobile binding so the core's ID-based profilemanager.ServiceManager owns profile state on iOS too, instead of a parallel Swift reimplementation. Adds client/ios/NetBirdSDK/profile_manager.go (//go:build ios): an ID-based ProfileManager wrapping ServiceManager with iOS-specific path handling (default profile at the container-root netbird.cfg, others as profiles/<id>.json) and a gomobile-friendly API: List/Add/Switch/Rename/ Logout/Remove plus active config/state path accessors. The default profile keeps the reserved "default" id and is never assigned a hex id. * fix(ios): preserve profile name when saving config during auth NewAuth built a fresh in-memory config from only the management URL, so the SSO/setup-key save (DirectWriteOutConfig) overwrote the profile config file the profile manager had just written, wiping the display name to "" and forcing the UI to fall back to the profile ID. Load the existing config when present and override only the management URL, keeping the name and keys. * [client] Extract the mobile profile manager into client/mobile The Android and iOS gomobile bindings carried two near-identical copies of the profile manager. Move the shared implementation into a new client/mobile package and reduce both bindings to thin adapters that only translate to gomobile-friendly types (gomobile binds per package, so the Profile / ProfileArray wrappers have to stay platform-side). Also bring the account-email layer over to the shared package: an SSO login records the account under <stem>.account.json so the next login can pass it as an OIDC login_hint. Logout keeps it, profile removal drops it. The suffix deliberately differs from .state.json, which the engine's state manager owns in the same directory on mobile. Adds profilemanager.Prefs (namespaced per-profile preference store) and its cleanup in ServiceManager.RemoveProfile, exposed through the shared manager as ProfilePrefs.
38 lines
843 B
Go
38 lines
843 B
Go
//go:build android
|
|
|
|
package android
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/netbirdio/netbird/client/internal/profilemanager"
|
|
)
|
|
|
|
type prefsStore interface {
|
|
Get(namespace string, v any) (bool, error)
|
|
Put(namespace string, v any) error
|
|
}
|
|
|
|
type profilePrefs struct {
|
|
prefs *profilemanager.Prefs
|
|
}
|
|
|
|
func newProfilePrefs(configDir, profileID string) (*profilePrefs, error) {
|
|
if configDir == "" || profileID == "" {
|
|
return nil, fmt.Errorf("profile prefs require a config dir and profile ID")
|
|
}
|
|
prefs, err := NewProfileManager(configDir).impl.ProfilePrefs(profileID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &profilePrefs{prefs: prefs}, nil
|
|
}
|
|
|
|
func (p *profilePrefs) Get(namespace string, v any) (bool, error) {
|
|
return p.prefs.Get(namespace, v)
|
|
}
|
|
|
|
func (p *profilePrefs) Put(namespace string, v any) error {
|
|
return p.prefs.Put(namespace, v)
|
|
}
|