Documentation ¶
Overview ¶
Package bridge implements the Bridge, which acts as the backend to the UI.
Index ¶
- Constants
- Variables
- func ApplyGluonCachePathSuffix(basePath string) string
- func ApplyGluonConfigPathSuffix(basePath string) string
- type Autostarter
- type Bridge
- func (bridge *Bridge) CheckForUpdates()
- func (bridge *Bridge) Close(ctx context.Context)
- func (bridge *Bridge) ConfigureAppleMail(userID, address string) error
- func (bridge *Bridge) DeleteUser(ctx context.Context, userID string) error
- 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) GetFirstStart() bool
- func (bridge *Bridge) GetGluonCacheDir() string
- func (bridge *Bridge) GetGluonDataDir() (string, error)
- func (bridge *Bridge) GetIMAPPort() int
- func (bridge *Bridge) GetIMAPSSL() bool
- func (bridge *Bridge) GetKeychainApp() (string, error)
- 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) GetUpdateChannel() updater.Channel
- func (bridge *Bridge) GetUserIDs() []string
- func (bridge *Bridge) GetUserInfo(userID string) (UserInfo, error)
- func (bridge *Bridge) HasUser(userID string) bool
- func (bridge *Bridge) InstallUpdate(version updater.VersionInfo)
- 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) PushError(err error)
- func (bridge *Bridge) QueryUserInfo(query string) (UserInfo, error)
- func (bridge *Bridge) ReportBug(ctx context.Context, ...) error
- 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) SetColorScheme(colorScheme string) error
- func (bridge *Bridge) SetCurrentPlatform(platform string)
- func (bridge *Bridge) SetGluonDir(ctx context.Context, newGluonDir string) error
- func (bridge *Bridge) SetIMAPPort(newPort int) error
- func (bridge *Bridge) SetIMAPSSL(newSSL bool) error
- func (bridge *Bridge) SetKeychainApp(helper string) error
- func (bridge *Bridge) SetProxyAllowed(allowed bool) error
- func (bridge *Bridge) SetSMTPPort(newPort int) error
- func (bridge *Bridge) SetSMTPSSL(newSSL bool) error
- func (bridge *Bridge) SetShowAllMail(show bool) error
- func (bridge *Bridge) SetUpdateChannel(channel updater.Channel) error
- type Identifier
- type Locator
- type Mocks
- type ProxyController
- type TLSReporter
- type TestCookieJar
- type TestLocationsProvider
- type TestUpdater
- func (testUpdater *TestUpdater) GetVersionInfo(ctx context.Context, downloader updater.Downloader, channel updater.Channel) (updater.VersionInfo, error)
- func (testUpdater *TestUpdater) InstallUpdate(ctx context.Context, downloader updater.Downloader, update updater.VersionInfo) error
- func (testUpdater *TestUpdater) SetLatestVersion(version, minAuto *semver.Version)
- type Updater
- type UserInfo
- type UserState
Constants ¶
const ( MaxTotalAttachmentSize = 7 * (1 << 20) MaxCompressedFilesCount = 6 )
Variables ¶
var ( ErrVaultInsecure = errors.New("the vault is insecure") ErrVaultCorrupt = errors.New("the vault is corrupt") ErrServeIMAP = errors.New("failed to serve IMAP") ErrServeSMTP = errors.New("failed to serve SMTP") 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") )
Functions ¶
func ApplyGluonCachePathSuffix ¶ added in v3.0.12
func ApplyGluonConfigPathSuffix ¶ added in v3.0.12
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, apiURL string, cookieJar http.CookieJar, identifier Identifier, tlsReporter TLSReporter, roundTripper http.RoundTripper, proxyCtl ProxyController, crashHandler async.PanicHandler, reporter reporter.Reporter, logIMAPClient, logIMAPServer bool, logSMTP bool, ) (*Bridge, <-chan events.Event, error)
New creates a new bridge.
func (*Bridge) CheckForUpdates ¶
func (bridge *Bridge) CheckForUpdates()
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) DeleteUser ¶
DeleteUser deletes the given user.
func (*Bridge) FactoryReset ¶
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) GetFirstStart ¶
func (*Bridge) GetGluonCacheDir ¶ added in v3.0.12
func (*Bridge) GetGluonDataDir ¶ added in v3.0.12
func (*Bridge) GetIMAPPort ¶
func (*Bridge) GetIMAPSSL ¶
func (*Bridge) GetKeychainApp ¶
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) GetUpdateChannel ¶
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) 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) LoginAuth ¶
func (bridge *Bridge) LoginAuth(ctx context.Context, username string, password []byte) (*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, ) (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) QueryUserInfo ¶
QueryUserInfo queries the user info by username or address.
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) SetColorScheme ¶
func (*Bridge) SetCurrentPlatform ¶
func (*Bridge) SetGluonDir ¶
func (*Bridge) SetIMAPPort ¶
func (*Bridge) SetIMAPSSL ¶
func (*Bridge) SetKeychainApp ¶
func (*Bridge) SetProxyAllowed ¶
func (*Bridge) SetSMTPPort ¶
func (*Bridge) SetSMTPSSL ¶
func (*Bridge) SetShowAllMail ¶
type Identifier ¶
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 }
type ProxyController ¶
type ProxyController interface { AllowProxy() DisallowProxy() }
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(ctx context.Context, downloader updater.Downloader, channel updater.Channel) (updater.VersionInfo, error)
func (*TestUpdater) InstallUpdate ¶
func (testUpdater *TestUpdater) InstallUpdate(ctx context.Context, downloader updater.Downloader, update updater.VersionInfo) 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 }
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 int // MaxSpace is the total amount of space available to the user. MaxSpace int }