store

package
v0.0.0-...-113f59a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package store provides various implementation of ipn.StateStore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(logf logger.Logf, path string) (ipn.StateStore, error)

New returns a StateStore based on the provided arg and registered stores. The arg is of the form "prefix:rest", where prefix was previously registered with Register.

By default the following stores are registered:

  • if the string begins with "mem:", the suffix is ignored and an in-memory store is used.
  • (Linux-only) if the string begins with "arn:", the suffix an AWS ARN for an SSM.
  • (Linux-only) if the string begins with "kube:", the suffix is a Kubernetes secret name
  • In all other cases, the path is treated as a filepath.

func NewFileStore

func NewFileStore(logf logger.Logf, path string) (ipn.StateStore, error)

NewFileStore returns a new file store that persists to path.

func Register

func Register(prefix string, fn Provider)

Register registers a prefix to be used for NewStore. It panics if the prefix is empty, or if the prefix is already registered. The provided fn is called with the path passed to NewStore; the prefix is not stripped.

func TryWindowsAppDataMigration

func TryWindowsAppDataMigration(logf logger.Logf, path string) string

TryWindowsAppDataMigration attempts to copy the Windows state file from its old location to the new location. (Issue 2856)

Tailscale 1.14 and before stored state under %LocalAppData% (usually "C:\WINDOWS\system32\config\systemprofile\AppData\Local" when tailscaled.exe is running as a non-user system service). However it is frequently cleared for almost any reason: Windows updates, System Restore, even various System Cleaner utilities.

Returns a string of the path to use for the state file. This will be a fallback %LocalAppData% path if migration fails, a %ProgramData% path otherwise.

Types

type FileStore

type FileStore struct {
	// contains filtered or unexported fields
}

FileStore is a StateStore that uses a JSON file for persistence.

func (*FileStore) Path

func (s *FileStore) Path() string

Path returns the path that NewFileStore was called with.

func (*FileStore) ReadState

func (s *FileStore) ReadState(id ipn.StateKey) ([]byte, error)

ReadState implements the StateStore interface.

func (*FileStore) String

func (s *FileStore) String() string

func (*FileStore) WriteState

func (s *FileStore) WriteState(id ipn.StateKey, bs []byte) error

WriteState implements the StateStore interface.

type Provider

type Provider func(logf logger.Logf, arg string) (ipn.StateStore, error)

Provider returns a StateStore for the provided path. The arg is of the form "prefix:rest", where prefix was previously registered with Register.

Directories

Path Synopsis
Package awsstore contains an ipn.StateStore implementation using AWS SSM.
Package awsstore contains an ipn.StateStore implementation using AWS SSM.
Package mem provides an in-memory ipn.StateStore implementation.
Package mem provides an in-memory ipn.StateStore implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL