Documentation ¶
Index ¶
- Constants
- Variables
- func GetDefaultSyncWorkerCount() int
- func GetHelper(vaultDir string) (string, error)
- func GetShouldSkipKeychainTest(vaultDir string) (bool, error)
- func GetVaultKey(kc *keychain.Keychain) ([]byte, error)
- func NewVaultKey(kc *keychain.Keychain) ([]byte, error)
- func SetHelper(vaultDir, helper string) error
- func SetShouldSkipKeychainTest(vaultDir string, skip bool) error
- func SetVaultKey(kc *keychain.Keychain, key []byte) error
- type AddressMode
- type Cert
- type Certs
- type Data
- type Data_2_3_x
- type Data_2_4_x
- type File
- type KeychainSettings
- type PasswordArchive
- type Settings
- type Settings_2_3_x
- type Settings_2_4_x
- type SyncStatus
- type User
- func (user *User) AddFailedMessageID(messageID string) error
- func (user *User) AddressMode() AddressMode
- func (user *User) AuthRef() string
- func (user *User) AuthUID() string
- func (user *User) BridgePass() []byte
- func (user *User) Clear() error
- func (user *User) ClearSyncStatusDeprecated() error
- func (user *User) ClearSyncStatusWithoutEventID() error
- func (user *User) Close() error
- func (user *User) EventID() string
- func (user *User) GetGluonIDs() map[string]string
- func (user *User) GetShouldResync() bool
- func (user *User) GetSyncStatusDeprecated() SyncStatus
- func (user *User) GluonKey() []byte
- func (user *User) KeyPass() []byte
- func (user *User) PrimaryEmail() string
- func (user *User) RemFailedMessageID(messageID string) error
- func (user *User) RemoveGluonID(addrID, gluonID string) error
- func (user *User) SetAddressMode(mode AddressMode) error
- func (user *User) SetAuth(authUID, authRef string) error
- func (user *User) SetBridgePass(newPass []byte) error
- func (user *User) SetEventID(eventID string) error
- func (user *User) SetGluonID(addrID, gluonID string) error
- func (user *User) SetHasLabels(hasLabels bool) error
- func (user *User) SetHasMessages(hasMessages bool) error
- func (user *User) SetKeyPass(keyPass []byte) error
- func (user *User) SetLastMessageID(messageID string) error
- func (user *User) SetPrimaryEmail(email string) error
- func (user *User) SetShouldSync(shouldResync bool) error
- func (user *User) SyncStatus() SyncStatus
- func (user *User) UserID() string
- func (user *User) Username() string
- type UserData
- type UserData_2_3_x
- type UserData_2_4_x
- type Vault
- func (vault *Vault) AddUser(userID, username, primaryEmail, authUID, authRef string, keyPass []byte) (*User, error)
- func (vault *Vault) Close() error
- func (vault *Vault) DeleteUser(userID string) error
- func (vault *Vault) ForUser(parallelism int, fn func(*User) error) error
- func (vault *Vault) GetAutoUpdate() bool
- func (vault *Vault) GetAutostart() bool
- func (vault *Vault) GetBridgeTLSCert() ([]byte, []byte)
- func (vault *Vault) GetColorScheme() string
- func (vault *Vault) GetCookies() ([]byte, error)
- func (vault *Vault) GetFirstStart() bool
- func (vault *Vault) GetGluonCacheDir() string
- func (vault *Vault) GetIMAPPort() int
- func (vault *Vault) GetIMAPSSL() bool
- func (vault *Vault) GetLastHeartbeatSent() time.Time
- func (vault *Vault) GetLastUserAgent() string
- func (vault *Vault) GetLastVersion() *semver.Version
- func (vault *Vault) GetMaxSyncMemory() uint64
- func (vault *Vault) GetOrAddUser(userID, username, primaryEmail, authUID, authRef string, keyPass []byte) (*User, bool, error)
- func (vault *Vault) GetProxyAllowed() bool
- func (vault *Vault) GetSMTPPort() int
- func (vault *Vault) GetSMTPSSL() bool
- func (vault *Vault) GetShowAllMail() bool
- func (vault *Vault) GetTelemetryDisabled() bool
- func (vault *Vault) GetUpdateChannel() updater.Channel
- func (vault *Vault) GetUpdateRollout() float64
- func (vault *Vault) GetUser(userID string, fn func(*User)) error
- func (vault *Vault) GetUserIDs() []string
- func (vault *Vault) HasUser(userID string) bool
- func (vault *Vault) Migrated() bool
- func (vault *Vault) NewUser(userID string) (*User, error)
- func (vault *Vault) Path() string
- func (vault *Vault) Reset(gluonDir string) error
- func (vault *Vault) SetAutoUpdate(autoUpdate bool) error
- func (vault *Vault) SetAutostart(autostart bool) error
- func (vault *Vault) SetBridgeTLSCertKey(cert, key []byte) error
- func (vault *Vault) SetBridgeTLSCertPath(certPath, keyPath string) error
- func (vault *Vault) SetColorScheme(colorScheme string) error
- func (vault *Vault) SetCookies(cookies []byte) error
- func (vault *Vault) SetFirstStart(firstStart bool) error
- func (vault *Vault) SetGluonDir(dir string) error
- func (vault *Vault) SetIMAPPort(port int) error
- func (vault *Vault) SetIMAPSSL(ssl bool) error
- func (vault *Vault) SetLastHeartbeatSent(timestamp time.Time) error
- func (vault *Vault) SetLastUserAgent(userAgent string) error
- func (vault *Vault) SetLastVersion(version *semver.Version) error
- func (vault *Vault) SetMaxSyncMemory(maxMemory uint64) error
- func (vault *Vault) SetMigrated() error
- func (vault *Vault) SetProxyAllowed(allowed bool) error
- func (vault *Vault) SetSMTPPort(port int) error
- func (vault *Vault) SetSMTPSSL(ssl bool) error
- func (vault *Vault) SetShowAllMail(showAllMail bool) error
- func (vault *Vault) SetTelemetryDisabled(telemetryDisabled bool) error
- func (vault *Vault) SetUpdateChannel(channel updater.Channel) error
- func (vault *Vault) SetUpdateRollout(rollout float64) error
- type Version
Constants ¶
const (
Current = v2_5_x
)
const DefaultMaxSyncMemory = 2 * 1024 * uint64(1024*1024)
const (
ForbiddenRollout = 0.6046602879796196
)
Variables ¶
var ErrDecryptFailed = errors.New("failed to decrypt vault")
var ErrUnmarshal = errors.New("vault contents are corrupt")
var RandomToken = crypto.RandomToken // nolint:gochecknoglobals
RandomToken is a function that returns a random token. By default, we use crypto.RandomToken to generate tokens.
Functions ¶
func GetDefaultSyncWorkerCount ¶
func GetDefaultSyncWorkerCount() int
func GetShouldSkipKeychainTest ¶ added in v3.13.0
func SetShouldSkipKeychainTest ¶ added in v3.13.0
Types ¶
type AddressMode ¶
type AddressMode int
const ( CombinedMode AddressMode = iota SplitMode )
func (AddressMode) String ¶
func (mode AddressMode) String() string
type Data_2_3_x ¶
type Data_2_3_x struct { Settings Settings_2_3_x Users []UserData_2_3_x }
type Data_2_4_x ¶
type Data_2_4_x struct { Settings Settings_2_4_x Users []UserData_2_4_x }
type KeychainSettings ¶ added in v3.13.0
type KeychainSettings struct { Helper string // The helper used for keychain. DisableTest bool // Is the keychain test on startup disabled? }
KeychainSettings holds settings related to the keychain. It is serialized in the vault directory.
func LoadKeychainSettings ¶ added in v3.13.0
func LoadKeychainSettings(vaultDir string) (KeychainSettings, error)
LoadKeychainSettings load keychain settings from the vaultDir folder, or returns a default one if the file does not exists or is invalid.
func (KeychainSettings) Save ¶ added in v3.13.0
func (k KeychainSettings) Save(vaultDir string) error
Save saves the keychain settings in a file in the vaultDir folder.
type PasswordArchive ¶ added in v3.3.0
type PasswordArchive struct { // we store the SHA-256 sum as string for readability and JSON marshalling of map[[32]byte][]byte will not be allowed, thus breaking vault-editor. Archive map[string][]byte }
PasswordArchive maps a list email address hashes to passwords. The type is not defined as a map alias to prevent having to handle nil default values when vault was created by an older version of the application.
type Settings ¶
type Settings struct { GluonDir string IMAPPort int SMTPPort int IMAPSSL bool SMTPSSL bool UpdateChannel updater.Channel UpdateRollout float64 ColorScheme string ProxyAllowed bool ShowAllMail bool Autostart bool AutoUpdate bool TelemetryDisabled bool LastVersion string FirstStart bool MaxSyncMemory uint64 LastUserAgent string LastHeartbeatSent time.Time PasswordArchive PasswordArchive // **WARNING**: These entry can't be removed until they vault has proper migration support. SyncWorkers int SyncAttPool int }
type Settings_2_3_x ¶
type Settings_2_4_x ¶
type SyncStatus ¶
type SyncStatus struct { HasLabels bool HasMessages bool LastMessageID string FailedMessageIDs []string }
func (SyncStatus) IsComplete ¶
func (status SyncStatus) IsComplete() bool
type User ¶
type User struct {
// contains filtered or unexported fields
}
func (*User) AddFailedMessageID ¶ added in v3.0.6
AddFailedMessageID adds a message ID to the list of failed message IDs.
func (*User) AddressMode ¶
func (user *User) AddressMode() AddressMode
AddressMode returns the user's address mode.
func (*User) BridgePass ¶
BridgePass returns the user's bridge password as raw token bytes (unencoded).
func (*User) ClearSyncStatusDeprecated ¶ added in v3.7.1
ClearSyncStatusDeprecated clears the user's sync status.
func (*User) ClearSyncStatusWithoutEventID ¶ added in v3.7.1
ClearSyncStatusWithoutEventID clears the user's sync status without modifying EventID.
func (*User) GetGluonIDs ¶
func (*User) GetShouldResync ¶ added in v3.12.0
func (*User) GetSyncStatusDeprecated ¶ added in v3.7.1
func (user *User) GetSyncStatusDeprecated() SyncStatus
GetSyncStatusDeprecated returns the user's sync status.
func (*User) PrimaryEmail ¶ added in v3.0.12
PrimaryEmail returns the user's primary email address.
func (*User) RemFailedMessageID ¶ added in v3.0.6
RemFailedMessageID removes a message ID from the list of failed message IDs.
func (*User) RemoveGluonID ¶
func (*User) SetAddressMode ¶
func (user *User) SetAddressMode(mode AddressMode) error
SetAddressMode sets the address mode for the given user.
func (*User) SetBridgePass ¶ added in v3.0.7
SetBridgePass saves bridge password as raw token bytes (unecoded).
func (*User) SetEventID ¶
SetEventID sets the event ID for the given user.
func (*User) SetGluonID ¶
func (*User) SetHasLabels ¶
SetHasLabels sets whether the user's labels have been synced.
func (*User) SetHasMessages ¶
SetHasMessages sets whether the user's messages have been synced.
func (*User) SetKeyPass ¶
SetKeyPass sets the user's (salted) key password.
func (*User) SetLastMessageID ¶
SetLastMessageID sets the last synced message ID for the given user.
func (*User) SetPrimaryEmail ¶ added in v3.0.12
SetPrimaryEmail sets the user's primary email address.
func (*User) SetShouldSync ¶ added in v3.12.0
func (*User) SyncStatus ¶
func (user *User) SyncStatus() SyncStatus
SyncStatus return's the user's sync status.
type UserData ¶
type UserData struct { UserID string Username string PrimaryEmail string GluonKey []byte GluonIDs map[string]string BridgePass []byte // raw token represented as byte slice (needs to be encoded) AddressMode AddressMode AuthUID string AuthRef string KeyPass []byte SyncStatus SyncStatus EventID string // **WARNING**: This value can't be removed until we have vault migration support. UIDValidity map[string]imap.UID ShouldResync bool // Whether user should re-sync on log-in (this is triggered by the `repair` button) }
UserData holds information about a single bridge user. The user may or may not be logged in.
type UserData_2_3_x ¶
type UserData_2_4_x ¶
type Vault ¶
type Vault struct {
// contains filtered or unexported fields
}
Vault is an encrypted data vault that stores bridge and user data.
func New ¶
func New(vaultDir, gluonCacheDir string, key []byte, panicHandler async.PanicHandler) (*Vault, error, error)
New constructs a new encrypted data vault at the given filepath using the given encryption key. The first error is a corruption error for an existing vault, the second errors refrain to all other errors.
func (*Vault) AddUser ¶
func (vault *Vault) AddUser(userID, username, primaryEmail, authUID, authRef string, keyPass []byte) (*User, error)
AddUser creates a new user in the vault with the given ID, username and password. A gluon key is generated using the package's token generator. If a password is found in the password archive for this user, it is restored, otherwise a new bridge password is generated using the package's token generator.
func (*Vault) DeleteUser ¶
DeleteUser removes the given user from the vault.
func (*Vault) GetAutoUpdate ¶
GetAutoUpdate sets whether the bridge should automatically update.
func (*Vault) GetAutostart ¶
GetAutostart sets whether the bridge should autostart.
func (*Vault) GetBridgeTLSCert ¶
GetBridgeTLSCert returns the PEM-encoded certificate for the bridge. If CertPEMPath is set, it will attempt to read the certificate from the file. Otherwise, or on read/validation failure, it will return the certificate from the vault.
func (*Vault) GetColorScheme ¶
GetColorScheme sets the color scheme to be used by the bridge GUI.
func (*Vault) GetCookies ¶
func (*Vault) GetFirstStart ¶
GetFirstStart returns whether this is the first time the bridge has been started.
func (*Vault) GetGluonCacheDir ¶ added in v3.0.12
GetGluonCacheDir sets the directory where the gluon should store its data.
func (*Vault) GetIMAPPort ¶
GetIMAPPort sets the port that the IMAP server should listen on.
func (*Vault) GetIMAPSSL ¶
GetIMAPSSL sets whether the IMAP server should use SSL.
func (*Vault) GetLastHeartbeatSent ¶ added in v3.2.0
GetLastHeartbeatSent returns the last time heartbeat was sent.
func (*Vault) GetLastUserAgent ¶ added in v3.2.0
GetLastUserAgent returns the last user agent recorded by bridge.
func (*Vault) GetLastVersion ¶
func (vault *Vault) GetLastVersion() *semver.Version
GetLastVersion returns the last version of the bridge that was run.
func (*Vault) GetMaxSyncMemory ¶ added in v3.1.0
GetMaxSyncMemory returns the maximum amount of memory the sync process should use.
func (*Vault) GetOrAddUser ¶ added in v3.3.0
func (vault *Vault) GetOrAddUser(userID, username, primaryEmail, authUID, authRef string, keyPass []byte) (*User, bool, error)
GetOrAddUser retrieves an existing user and updates the authRef and keyPass or creates a new user. Returns the user and whether the user did not exist before.
func (*Vault) GetProxyAllowed ¶
GetProxyAllowed sets whether the bridge is allowed to use alternative routing.
func (*Vault) GetSMTPPort ¶
GetSMTPPort sets the port that the SMTP server should listen on.
func (*Vault) GetSMTPSSL ¶
GetSMTPSSL sets whether the SMTP server should use SSL.
func (*Vault) GetShowAllMail ¶
GetShowAllMail sets whether the bridge should show the All Mail folder.
func (*Vault) GetTelemetryDisabled ¶ added in v3.2.0
GetTelemetryDisabled checks whether telemetry is disabled.
func (*Vault) GetUpdateChannel ¶
GetUpdateChannel sets the update channel.
func (*Vault) GetUpdateRollout ¶
GetUpdateRollout sets the update rollout.
func (*Vault) GetUser ¶
GetUser provides access to a vault user. It returns an error if the user does not exist.
func (*Vault) GetUserIDs ¶
GetUserIDs returns the user IDs and usernames of all users in the vault.
func (*Vault) NewUser ¶
NewUser returns a new vault user. It must be closed before it can be deleted.
func (*Vault) SetAutoUpdate ¶
SetAutoUpdate sets whether the bridge should automatically update.
func (*Vault) SetAutostart ¶
SetAutostart sets whether the bridge should autostart.
func (*Vault) SetBridgeTLSCertKey ¶ added in v3.0.21
SetBridgeTLSCertKey sets the path to PEM-encoded certificates for the bridge.
func (*Vault) SetBridgeTLSCertPath ¶ added in v3.1.0
SetBridgeTLSCertPath sets the path to PEM-encoded certificates for the bridge.
func (*Vault) SetColorScheme ¶
SetColorScheme sets the color scheme to be used by the bridge GUI.
func (*Vault) SetCookies ¶
func (*Vault) SetFirstStart ¶
SetFirstStart sets whether this is the first time the bridge has been started.
func (*Vault) SetGluonDir ¶
SetGluonDir sets the directory where the gluon should store its data.
func (*Vault) SetIMAPPort ¶
SetIMAPPort sets the port that the IMAP server should listen on.
func (*Vault) SetIMAPSSL ¶
SetIMAPSSL sets whether the IMAP server should use SSL.
func (*Vault) SetLastHeartbeatSent ¶ added in v3.2.0
SetLastHeartbeatSent store the last time heartbeat was sent.
func (*Vault) SetLastUserAgent ¶ added in v3.2.0
SetLastUserAgent store the last user agent recorded by bridge.
func (*Vault) SetLastVersion ¶
SetLastVersion sets the last version of the bridge that was run.
func (*Vault) SetMaxSyncMemory ¶ added in v3.1.0
SetMaxSyncMemory sets the maximum amount of memory the sync process should use.
func (*Vault) SetMigrated ¶
func (*Vault) SetProxyAllowed ¶
SetProxyAllowed sets whether the bridge is allowed to use alternative routing.
func (*Vault) SetSMTPPort ¶
SetSMTPPort sets the port that the SMTP server should listen on.
func (*Vault) SetSMTPSSL ¶
SetSMTPSSL sets whether the SMTP server should use SSL.
func (*Vault) SetShowAllMail ¶
SetShowAllMail sets whether the bridge should show the All Mail folder.
func (*Vault) SetTelemetryDisabled ¶ added in v3.2.0
SetTelemetryDisabled sets whether telemetry is disabled.
func (*Vault) SetUpdateChannel ¶
SetUpdateChannel sets the update channel.
func (*Vault) SetUpdateRollout ¶
SetUpdateRollout sets the update rollout.