Documentation ¶
Overview ¶
Package bridge implements the Bridge, which acts as the backend to the UI.
Index ¶
- Constants
- Variables
- func GetUpdatedCachePath(gluonDBPath, gluonCachePath string) string
- type Autostarter
- type Bridge
- func (bridge *Bridge) AutoconfigUsed(client string)
- func (bridge *Bridge) CheckClientState(ctx context.Context, checkFlags bool, progressCB func(string)) (CheckClientStateResult, error)
- func (bridge *Bridge) CheckForUpdates()
- func (bridge *Bridge) Close(ctx context.Context)
- func (bridge *Bridge) CollectLogs() (proton.ReportBugAttachment, error)
- func (bridge *Bridge) ConfigureAppleMail(ctx context.Context, userID, address string) error
- func (bridge *Bridge) DebugDownloadFailedMessages(ctx context.Context, result CheckClientStateResult, exportPath string, ...) error
- func (bridge *Bridge) DeleteUser(ctx context.Context, userID string) error
- func (bridge *Bridge) ExternalLinkClicked(article string)
- func (bridge *Bridge) FactoryReset(ctx context.Context)
- func (bridge *Bridge) GetAutoUpdate() bool
- func (bridge *Bridge) GetAutostart() bool
- func (bridge *Bridge) GetBridgeTLSCert() ([]byte, []byte)
- func (bridge *Bridge) GetColorScheme() string
- func (bridge *Bridge) GetCurrentUserAgent() string
- func (bridge *Bridge) GetCurrentVersion() *semver.Version
- func (bridge *Bridge) GetDependencyLicensesLink() string
- func (bridge *Bridge) GetErrors() []error
- func (bridge *Bridge) GetEvents(ofType ...events.Event) (<-chan events.Event, context.CancelFunc)
- func (bridge *Bridge) GetFeatureFlagValue(key string) bool
- func (bridge *Bridge) GetFirstStart() bool
- func (bridge *Bridge) GetGluonCacheDir() string
- func (bridge *Bridge) GetGluonDataDir() (string, error)
- func (bridge *Bridge) GetHeartbeatPeriodicInterval() time.Duration
- func (bridge *Bridge) GetHelpersNames() []string
- func (bridge *Bridge) GetIMAPPort() int
- func (bridge *Bridge) GetIMAPSSL() bool
- func (bridge *Bridge) GetKeychainApp() (string, error)
- func (bridge *Bridge) GetKnowledgeBaseSuggestions(userInput string) (kb.ArticleList, error)
- func (bridge *Bridge) GetLastHeartbeatSent() time.Time
- func (bridge *Bridge) GetLastVersion() *semver.Version
- func (bridge *Bridge) GetLicenseFilePath() string
- func (bridge *Bridge) GetLogsPath() (string, error)
- func (bridge *Bridge) GetProxyAllowed() bool
- func (bridge *Bridge) GetSMTPPort() int
- func (bridge *Bridge) GetSMTPSSL() bool
- func (bridge *Bridge) GetShowAllMail() bool
- func (bridge *Bridge) GetTelemetryDisabled() bool
- func (bridge *Bridge) GetUpdateChannel() updater.Channel
- func (bridge *Bridge) GetUpdateRollout() float64
- func (bridge *Bridge) GetUserIDs() []string
- func (bridge *Bridge) GetUserInfo(userID string) (UserInfo, error)
- func (bridge *Bridge) HasAPIConnection() bool
- func (bridge *Bridge) HasUser(userID string) bool
- func (bridge *Bridge) InstallUpdate(version updater.VersionInfo)
- func (bridge *Bridge) IsTelemetryAvailable(ctx context.Context) bool
- func (bridge *Bridge) LoginAuth(ctx context.Context, username string, password []byte, ...) (*proton.Client, proton.Auth, error)
- func (bridge *Bridge) LoginFull(ctx context.Context, username string, password []byte, ...) (string, error)
- func (bridge *Bridge) LoginUser(ctx context.Context, client *proton.Client, auth proton.Auth, keyPass []byte, ...) (string, error)
- func (bridge *Bridge) LogoutUser(ctx context.Context, userID string) error
- func (bridge *Bridge) ModifyObservabilityHeartbeatInterval(duration time.Duration)
- func (bridge *Bridge) PushDistinctObservabilityMetrics(errType observability.DistinctionErrorTypeEnum, ...)
- func (bridge *Bridge) PushError(err error)
- func (bridge *Bridge) PushObservabilityMetric(metric proton.ObservabilityMetric)
- func (bridge *Bridge) QueryUserInfo(query string) (UserInfo, error)
- func (bridge *Bridge) RemoveOldUpdates()
- func (bridge *Bridge) Repair()
- func (bridge *Bridge) ReportBug(ctx context.Context, report *ReportBugReq) error
- func (bridge *Bridge) ReportBugClicked()
- func (bridge *Bridge) SendBadEventUserFeedback(_ context.Context, userID string, doResync bool) error
- func (bridge *Bridge) SendHeartbeat(ctx context.Context, heartbeat *telemetry.HeartbeatData) bool
- func (bridge *Bridge) SetAddressMode(ctx context.Context, userID string, mode vault.AddressMode) error
- func (bridge *Bridge) SetAutoUpdate(autoUpdate bool) error
- func (bridge *Bridge) SetAutostart(autostart bool) error
- func (bridge *Bridge) SetBridgeTLSCertPath(certPath, keyPath string) error
- func (bridge *Bridge) SetColorScheme(colorScheme string) error
- func (bridge *Bridge) SetCurrentPlatform(platform string)
- func (bridge *Bridge) SetGluonDir(ctx context.Context, newGluonDir string) error
- func (bridge *Bridge) SetIMAPPort(ctx context.Context, newPort int) error
- func (bridge *Bridge) SetIMAPSSL(ctx context.Context, newSSL bool) error
- func (bridge *Bridge) SetKeychainApp(helper string) error
- func (bridge *Bridge) SetLastHeartbeatSent(timestamp time.Time) error
- func (bridge *Bridge) SetProxyAllowed(allowed bool) error
- func (bridge *Bridge) SetSMTPPort(ctx context.Context, newPort int) error
- func (bridge *Bridge) SetSMTPSSL(ctx context.Context, newSSL bool) error
- func (bridge *Bridge) SetShowAllMail(show bool) error
- func (bridge *Bridge) SetTelemetryDisabled(isDisabled bool) error
- func (bridge *Bridge) SetUpdateChannel(channel updater.Channel) error
- type CheckClientStateResult
- type Locator
- type Mocks
- type ProxyController
- type ReportBugReq
- type TLSReporter
- type TestCookieJar
- type TestLocationsProvider
- type TestUpdater
- func (testUpdater *TestUpdater) GetVersionInfo(_ context.Context, _ updater.Downloader, _ updater.Channel) (updater.VersionInfo, error)
- func (testUpdater *TestUpdater) InstallUpdate(_ context.Context, _ updater.Downloader, _ updater.VersionInfo) error
- func (testUpdater *TestUpdater) RemoveOldUpdates() error
- func (testUpdater *TestUpdater) SetLatestVersion(version, minAuto *semver.Version)
- type Updater
- type UserInfo
- type UserState
Constants ¶
const ( DefaultMaxBugReportZipSize = 7 * 1024 * 1024 DefaultMaxSessionCountForBugReport = 10 )
const HeartbeatCheckInterval = time.Hour
Variables ¶
var ( ErrVaultInsecure = errors.New("the vault is insecure") ErrVaultCorrupt = errors.New("the vault is corrupt") ErrWatchUpdates = errors.New("failed to watch for updates") ErrNoSuchUser = errors.New("no such user") ErrUserAlreadyExists = errors.New("user already exists") ErrUserAlreadyLoggedIn = errors.New("the user is already logged in") ErrNotImplemented = errors.New("not implemented") ErrSizeTooLarge = errors.New("file is too big") )
var ErrFailedToUnlock = errors.New("failed to unlock user keys")
Functions ¶
func GetUpdatedCachePath ¶ added in v3.13.0
Types ¶
type Autostarter ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
func New ¶
func New( locator Locator, vault *vault.Vault, autostarter Autostarter, updater Updater, curVersion *semver.Version, keychains *keychain.List, apiURL string, cookieJar http.CookieJar, identifier identifier.Identifier, tlsReporter TLSReporter, roundTripper http.RoundTripper, proxyCtl ProxyController, panicHandler async.PanicHandler, reporter reporter.Reporter, uidValidityGenerator imap.UIDValidityGenerator, heartBeatManager telemetry.HeartbeatManager, logIMAPClient, logIMAPServer bool, logSMTP bool, ) (*Bridge, <-chan events.Event, error)
New creates a new bridge.
func (*Bridge) AutoconfigUsed ¶ added in v3.3.1
func (*Bridge) CheckClientState ¶ added in v3.4.0
func (bridge *Bridge) CheckClientState(ctx context.Context, checkFlags bool, progressCB func(string)) (CheckClientStateResult, error)
CheckClientState checks the current IMAP client reported state against the proton server state and reports anything that is out of place.
func (*Bridge) CheckForUpdates ¶
func (bridge *Bridge) CheckForUpdates()
func (*Bridge) CollectLogs ¶ added in v3.7.0
func (*Bridge) ConfigureAppleMail ¶
ConfigureAppleMail configures Apple Mail for the given userID and address. If configuring Apple Mail for Catalina or newer, it ensures Bridge is using SSL.
func (*Bridge) DebugDownloadFailedMessages ¶ added in v3.4.0
func (*Bridge) DeleteUser ¶
DeleteUser deletes the given user.
func (*Bridge) ExternalLinkClicked ¶ added in v3.8.0
func (*Bridge) FactoryReset ¶
FactoryReset deletes all users, wipes the vault, and deletes all files. Note: it does not clear the keychain. The only entry in the keychain is the vault password, which we need at next startup to decrypt the vault.
func (*Bridge) GetAutoUpdate ¶
func (*Bridge) GetAutostart ¶
func (*Bridge) GetBridgeTLSCert ¶
func (*Bridge) GetColorScheme ¶
func (*Bridge) GetCurrentUserAgent ¶
func (*Bridge) GetCurrentVersion ¶
func (bridge *Bridge) GetCurrentVersion() *semver.Version
func (*Bridge) GetDependencyLicensesLink ¶
func (*Bridge) GetEvents ¶
GetEvents returns a channel of events of the given type. If no types are supplied, all events are returned.
func (*Bridge) GetFeatureFlagValue ¶ added in v3.13.0
func (*Bridge) GetFirstStart ¶
func (*Bridge) GetGluonCacheDir ¶ added in v3.0.12
func (*Bridge) GetGluonDataDir ¶ added in v3.0.12
func (*Bridge) GetHeartbeatPeriodicInterval ¶ added in v3.7.1
func (*Bridge) GetHelpersNames ¶ added in v3.7.1
func (*Bridge) GetIMAPPort ¶
func (*Bridge) GetIMAPSSL ¶
func (*Bridge) GetKeychainApp ¶
func (*Bridge) GetKnowledgeBaseSuggestions ¶ added in v3.8.1
func (bridge *Bridge) GetKnowledgeBaseSuggestions(userInput string) (kb.ArticleList, error)
func (*Bridge) GetLastHeartbeatSent ¶ added in v3.2.0
func (*Bridge) GetLastVersion ¶
func (bridge *Bridge) GetLastVersion() *semver.Version
func (*Bridge) GetLicenseFilePath ¶
func (*Bridge) GetLogsPath ¶
func (*Bridge) GetProxyAllowed ¶
func (*Bridge) GetSMTPPort ¶
func (*Bridge) GetSMTPSSL ¶
func (*Bridge) GetShowAllMail ¶
func (*Bridge) GetTelemetryDisabled ¶ added in v3.2.0
func (*Bridge) GetUpdateChannel ¶
func (*Bridge) GetUpdateRollout ¶ added in v3.2.0
func (*Bridge) GetUserIDs ¶
GetUserIDs returns the IDs of all known users (authorized or not).
func (*Bridge) GetUserInfo ¶
GetUserInfo returns info about the given user.
func (*Bridge) HasAPIConnection ¶ added in v3.12.0
func (*Bridge) HasUser ¶ added in v3.0.9
HasUser returns true iff the given user is known (authorized or not).
func (*Bridge) InstallUpdate ¶
func (bridge *Bridge) InstallUpdate(version updater.VersionInfo)
func (*Bridge) IsTelemetryAvailable ¶ added in v3.2.0
func (*Bridge) LoginAuth ¶
func (bridge *Bridge) LoginAuth(ctx context.Context, username string, password []byte, hvDetails *proton.APIHVDetails) (*proton.Client, proton.Auth, error)
LoginAuth begins the login process. It returns an authorized client that might need 2FA.
func (*Bridge) LoginFull ¶
func (bridge *Bridge) LoginFull( ctx context.Context, username string, password []byte, getTOTP func() (string, error), getKeyPass func() ([]byte, error), ) (string, error)
LoginFull authorizes a new bridge user with the given username and password. If necessary, a TOTP and mailbox password are requested via the callbacks. This is equivalent to doing LoginAuth and LoginUser separately.
func (*Bridge) LoginUser ¶
func (bridge *Bridge) LoginUser( ctx context.Context, client *proton.Client, auth proton.Auth, keyPass []byte, hvDetails *proton.APIHVDetails, ) (string, error)
LoginUser finishes the user login process using the client and auth received from LoginAuth.
func (*Bridge) LogoutUser ¶
LogoutUser logs out the given user.
func (*Bridge) ModifyObservabilityHeartbeatInterval ¶ added in v3.14.0
func (*Bridge) PushDistinctObservabilityMetrics ¶ added in v3.14.0
func (bridge *Bridge) PushDistinctObservabilityMetrics(errType observability.DistinctionErrorTypeEnum, metrics ...proton.ObservabilityMetric)
func (*Bridge) PushObservabilityMetric ¶ added in v3.13.0
func (bridge *Bridge) PushObservabilityMetric(metric proton.ObservabilityMetric)
func (*Bridge) QueryUserInfo ¶
QueryUserInfo queries the user info by username or address.
func (*Bridge) RemoveOldUpdates ¶ added in v3.7.0
func (bridge *Bridge) RemoveOldUpdates()
func (*Bridge) ReportBug ¶
func (bridge *Bridge) ReportBug(ctx context.Context, report *ReportBugReq) error
func (*Bridge) ReportBugClicked ¶ added in v3.3.1
func (bridge *Bridge) ReportBugClicked()
func (*Bridge) SendBadEventUserFeedback ¶ added in v3.0.20
func (bridge *Bridge) SendBadEventUserFeedback(_ context.Context, userID string, doResync bool) error
SendBadEventUserFeedback passes the feedback to the given user.
func (*Bridge) SendHeartbeat ¶ added in v3.2.0
func (*Bridge) SetAddressMode ¶
func (bridge *Bridge) SetAddressMode(ctx context.Context, userID string, mode vault.AddressMode) error
SetAddressMode sets the address mode for the given user.
func (*Bridge) SetAutoUpdate ¶
func (*Bridge) SetAutostart ¶
func (*Bridge) SetBridgeTLSCertPath ¶ added in v3.1.0
func (*Bridge) SetColorScheme ¶
func (*Bridge) SetCurrentPlatform ¶
func (*Bridge) SetGluonDir ¶
func (*Bridge) SetIMAPPort ¶
func (*Bridge) SetIMAPSSL ¶
func (*Bridge) SetKeychainApp ¶
func (*Bridge) SetLastHeartbeatSent ¶ added in v3.2.0
func (*Bridge) SetProxyAllowed ¶
func (*Bridge) SetSMTPPort ¶
func (*Bridge) SetSMTPSSL ¶
func (*Bridge) SetShowAllMail ¶
func (*Bridge) SetTelemetryDisabled ¶ added in v3.2.0
type CheckClientStateResult ¶ added in v3.4.0
type CheckClientStateResult struct {
MissingMessages map[string]map[string]user.DiagMailboxMessage
}
func (*CheckClientStateResult) AddMissingMessage ¶ added in v3.4.0
func (c *CheckClientStateResult) AddMissingMessage(userID string, message user.DiagMailboxMessage)
type Locator ¶
type Locator interface { ProvideSettingsPath() (string, error) ProvideLogsPath() (string, error) ProvideGluonCachePath() (string, error) ProvideGluonDataPath() (string, error) ProvideStatsPath() (string, error) GetLicenseFilePath() string GetDependencyLicensesLink() string Clear(...string) error ProvideIMAPSyncConfigPath() (string, error) ProvideUnleashCachePath() (string, error) ProvideNotificationsCachePath() (string, error) }
type Mocks ¶
type Mocks struct { ProxyCtl *mocks.MockProxyController TLSReporter *mocks.MockTLSReporter TLSIssueCh chan struct{} Updater *TestUpdater Autostarter *mocks.MockAutostarter CrashHandler *mocks.MockPanicHandler Reporter *mocks.MockReporter Heartbeat *mocks.MockHeartbeatManager }
type ProxyController ¶
type ProxyController interface { AllowProxy() DisallowProxy() }
type ReportBugReq ¶ added in v3.7.0
type TLSReporter ¶
type TLSReporter interface {
GetTLSIssueCh() <-chan struct{}
}
type TestCookieJar ¶
type TestCookieJar struct {
// contains filtered or unexported fields
}
func NewTestCookieJar ¶
func NewTestCookieJar() *TestCookieJar
func (*TestCookieJar) SetCookies ¶
func (j *TestCookieJar) SetCookies(u *url.URL, cookies []*http.Cookie)
type TestLocationsProvider ¶
type TestLocationsProvider struct {
// contains filtered or unexported fields
}
func NewTestLocationsProvider ¶
func NewTestLocationsProvider(dir string) *TestLocationsProvider
func (*TestLocationsProvider) UserCache ¶
func (provider *TestLocationsProvider) UserCache() string
func (*TestLocationsProvider) UserConfig ¶
func (provider *TestLocationsProvider) UserConfig() string
func (*TestLocationsProvider) UserData ¶
func (provider *TestLocationsProvider) UserData() string
type TestUpdater ¶
type TestUpdater struct {
// contains filtered or unexported fields
}
func NewTestUpdater ¶
func NewTestUpdater(version, minAuto *semver.Version) *TestUpdater
func (*TestUpdater) GetVersionInfo ¶
func (testUpdater *TestUpdater) GetVersionInfo(_ context.Context, _ updater.Downloader, _ updater.Channel) (updater.VersionInfo, error)
func (*TestUpdater) InstallUpdate ¶
func (testUpdater *TestUpdater) InstallUpdate(_ context.Context, _ updater.Downloader, _ updater.VersionInfo) error
func (*TestUpdater) RemoveOldUpdates ¶ added in v3.7.0
func (testUpdater *TestUpdater) RemoveOldUpdates() error
func (*TestUpdater) SetLatestVersion ¶
func (testUpdater *TestUpdater) SetLatestVersion(version, minAuto *semver.Version)
type Updater ¶
type Updater interface { GetVersionInfo(context.Context, updater.Downloader, updater.Channel) (updater.VersionInfo, error) InstallUpdate(context.Context, updater.Downloader, updater.VersionInfo) error RemoveOldUpdates() error }
type UserInfo ¶
type UserInfo struct { // UserID is the user's API ID. UserID string // Username is the user's API username. Username string // Signed Out is true if the user is signed out (no AuthUID, user will need to provide credentials to log in again) State UserState // Addresses holds the user's email addresses. The first address is the primary address. Addresses []string // AddressMode is the user's address mode. AddressMode vault.AddressMode // BridgePass is the user's bridge password. BridgePass []byte // UsedSpace is the amount of space used by the user. UsedSpace uint64 // MaxSpace is the total amount of space available to the user. MaxSpace uint64 }