feature,client: add serviceclientprefs for desktop client service launch (#20501)
Add serviceclientprefs, an optional feature that stores and loads the desktop clients' saved service launch preferences, one file per login profile. - Add GET|POST /localapi/v0/prefs/service-clients to load and save the current profile's service client prefs. - Add local client GetServiceClientPrefs and SetServiceClientPref that call the new local api endpoint. - Store the prefs with the ipn/store FileStore at TailscaleVarRoot()/profile-data/<profileID>/service-client-prefs/<hex-encoded-key>, so DeleteProfile cleans them up for free. Fall back to an in-memory store when there's no var root. - Register the feature and its local api route from build tagged files so the whole thing drops out under ts_omit_serviceclientprefs. - Add the serviceclient package holding Pref and Prefs (saved client, username, database name, and last used time), so the local api client and desktop apps can import the types without the feature machinery. Change-Id: I340a99c1b332d181fb1556fbf3e8003bb3b95a08 Updates: https://github.com/tailscale/tailscale/issues/20429 Signed-off-by: Rollie Ma <rollie@tailscale.com>
This commit is contained in:
@@ -6296,6 +6296,9 @@ func (b *LocalBackend) ProfileMkdirAll(id ipn.ProfileID, subs ...string) (string
|
||||
return b.profileMkdirAllLocked(id, subs...)
|
||||
}
|
||||
|
||||
// ProfileDataDir is the directory name, under the Tailscale var root, that holds per-profile data.
|
||||
const ProfileDataDir = "profile-data"
|
||||
|
||||
// profileDataPathLocked returns a path of a profile-specific (sub)directory
|
||||
// inside the writable storage area for the given profile ID. It does not
|
||||
// create or verify the existence of the path in the filesystem.
|
||||
@@ -6310,7 +6313,7 @@ func (b *LocalBackend) profileDataPathLocked(id ipn.ProfileID, subs ...string) s
|
||||
if vr == "" {
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(append([]string{vr, "profile-data", string(id)}, subs...)...)
|
||||
return filepath.Join(append([]string{vr, ProfileDataDir, string(id)}, subs...)...)
|
||||
}
|
||||
|
||||
// profileMkdirAllLocked implements ProfileMkdirAll.
|
||||
|
||||
Reference in New Issue
Block a user