From 7b254cb966eeca3fe5d11620fb317087618930f5 Mon Sep 17 00:00:00 2001 From: pascal-fischer <32096965+pascal-fischer@users.noreply.github.com> Date: Tue, 23 Apr 2024 19:26:03 +0200 Subject: [PATCH] add methods to manage rosenpass settings for iOS (#1879) --- client/ios/NetBirdSDK/preferences.go | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/client/ios/NetBirdSDK/preferences.go b/client/ios/NetBirdSDK/preferences.go index 297d53ff0..b78146679 100644 --- a/client/ios/NetBirdSDK/preferences.go +++ b/client/ios/NetBirdSDK/preferences.go @@ -71,6 +71,42 @@ func (p *Preferences) SetPreSharedKey(key string) { p.configInput.PreSharedKey = &key } +// SetRosenpassEnabled store if rosenpass is enabled +func (p *Preferences) SetRosenpassEnabled(enabled bool) { + p.configInput.RosenpassEnabled = &enabled +} + +// GetRosenpassEnabled read rosenpass enabled from config file +func (p *Preferences) GetRosenpassEnabled() (bool, error) { + if p.configInput.RosenpassEnabled != nil { + return *p.configInput.RosenpassEnabled, nil + } + + cfg, err := internal.ReadConfig(p.configInput.ConfigPath) + if err != nil { + return false, err + } + return cfg.RosenpassEnabled, err +} + +// SetRosenpassPermissive store the given permissive and wait for commit +func (p *Preferences) SetRosenpassPermissive(permissive bool) { + p.configInput.RosenpassPermissive = &permissive +} + +// GetRosenpassPermissive read rosenpass permissive from config file +func (p *Preferences) GetRosenpassPermissive() (bool, error) { + if p.configInput.RosenpassPermissive != nil { + return *p.configInput.RosenpassPermissive, nil + } + + cfg, err := internal.ReadConfig(p.configInput.ConfigPath) + if err != nil { + return false, err + } + return cfg.RosenpassPermissive, err +} + // Commit write out the changes into config file func (p *Preferences) Commit() error { _, err := internal.UpdateOrCreateConfig(p.configInput)