mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-31 20:11:31 +02:00
Which applications the tunnel carries belongs with the rest of a profile's preferences rather than on the Android side, so the choice follows the profile the user is on. Adds a split tunnel store beside the SSH session store, over a "split-tunnel" namespace holding the mode and both selections. The two selections are kept apart because the platform applies an allow list or a deny list and never both, and so that switching mode does not throw away the picks made in the other one. Only the store itself needs the android build tag; the rest stays untagged so it is covered by the package's host tests.
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
//go:build android
|
|
|
|
package android
|
|
|
|
const splitTunnelNamespace = "split-tunnel"
|
|
|
|
// SplitTunnelStore reads and writes a profile's split tunnelling settings.
|
|
type SplitTunnelStore struct {
|
|
prefs prefsStore
|
|
}
|
|
|
|
// NewSplitTunnelStore opens the split tunnelling store of the given profile.
|
|
func NewSplitTunnelStore(configDir, profileID string) (*SplitTunnelStore, error) {
|
|
prefs, err := newProfilePrefs(configDir, profileID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &SplitTunnelStore{prefs: prefs}, nil
|
|
}
|
|
|
|
// Load returns the stored settings, or settings that carry every application
|
|
// when the profile has none saved.
|
|
func (s *SplitTunnelStore) Load() (*SplitTunnelSettings, error) {
|
|
var section splitTunnelSection
|
|
if _, err := s.prefs.Get(splitTunnelNamespace, §ion); err != nil {
|
|
return nil, err
|
|
}
|
|
return settingsFromSection(section), nil
|
|
}
|
|
|
|
// Save replaces the stored settings.
|
|
func (s *SplitTunnelStore) Save(settings *SplitTunnelSettings) error {
|
|
return s.prefs.Put(splitTunnelNamespace, sectionFromSettings(settings))
|
|
}
|