bridge

package
v3.11.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 54 Imported by: 0

Documentation

Overview

Package bridge implements the Bridge, which acts as the backend to the UI.

Index

Constants

View Source
const (
	DefaultMaxBugReportZipSize         = 7 * 1024 * 1024
	DefaultMaxSessionCountForBugReport = 10
)
View Source
const HeartbeatCheckInterval = time.Hour

Variables

View Source
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")
)
View Source
var ErrFailedToUnlock = errors.New("failed to unlock user keys")

Functions

This section is empty.

Types

type Autostarter

type Autostarter interface {
	Enable() error
	Disable() error
	IsEnabled() bool
}

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 *Bridge) AutoconfigUsed(client string)

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) Close

func (bridge *Bridge) Close(ctx context.Context)

func (*Bridge) CollectLogs added in v3.7.0

func (bridge *Bridge) CollectLogs() (proton.ReportBugAttachment, error)

func (*Bridge) ConfigureAppleMail

func (bridge *Bridge) ConfigureAppleMail(ctx context.Context, userID, address string) error

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 *Bridge) DebugDownloadFailedMessages(
	ctx context.Context,
	result CheckClientStateResult,
	exportPath string,
	progressCB func(string, int, int),
) error

func (*Bridge) DeleteUser

func (bridge *Bridge) DeleteUser(ctx context.Context, userID string) error

DeleteUser deletes the given user.

func (*Bridge) ExternalLinkClicked added in v3.8.0

func (bridge *Bridge) ExternalLinkClicked(article string)

func (*Bridge) FactoryReset

func (bridge *Bridge) FactoryReset(ctx context.Context)

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 *Bridge) GetAutoUpdate() bool

func (*Bridge) GetAutostart

func (bridge *Bridge) GetAutostart() bool

func (*Bridge) GetBridgeTLSCert

func (bridge *Bridge) GetBridgeTLSCert() ([]byte, []byte)

func (*Bridge) GetColorScheme

func (bridge *Bridge) GetColorScheme() string

func (*Bridge) GetCurrentUserAgent

func (bridge *Bridge) GetCurrentUserAgent() string

func (*Bridge) GetCurrentVersion

func (bridge *Bridge) GetCurrentVersion() *semver.Version
func (bridge *Bridge) GetDependencyLicensesLink() string

func (*Bridge) GetErrors

func (bridge *Bridge) GetErrors() []error

func (*Bridge) GetEvents

func (bridge *Bridge) GetEvents(ofType ...events.Event) (<-chan events.Event, context.CancelFunc)

GetEvents returns a channel of events of the given type. If no types are supplied, all events are returned.

func (*Bridge) GetFirstStart

func (bridge *Bridge) GetFirstStart() bool

func (*Bridge) GetGluonCacheDir added in v3.0.12

func (bridge *Bridge) GetGluonCacheDir() string

func (*Bridge) GetGluonDataDir added in v3.0.12

func (bridge *Bridge) GetGluonDataDir() (string, error)

func (*Bridge) GetHeartbeatPeriodicInterval added in v3.7.1

func (bridge *Bridge) GetHeartbeatPeriodicInterval() time.Duration

func (*Bridge) GetHelpersNames added in v3.7.1

func (bridge *Bridge) GetHelpersNames() []string

func (*Bridge) GetIMAPPort

func (bridge *Bridge) GetIMAPPort() int

func (*Bridge) GetIMAPSSL

func (bridge *Bridge) GetIMAPSSL() bool

func (*Bridge) GetKeychainApp

func (bridge *Bridge) GetKeychainApp() (string, error)

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 *Bridge) GetLastHeartbeatSent() time.Time

func (*Bridge) GetLastVersion

func (bridge *Bridge) GetLastVersion() *semver.Version

func (*Bridge) GetLicenseFilePath

func (bridge *Bridge) GetLicenseFilePath() string

func (*Bridge) GetLogsPath

func (bridge *Bridge) GetLogsPath() (string, error)

func (*Bridge) GetProxyAllowed

func (bridge *Bridge) GetProxyAllowed() bool

func (*Bridge) GetSMTPPort

func (bridge *Bridge) GetSMTPPort() int

func (*Bridge) GetSMTPSSL

func (bridge *Bridge) GetSMTPSSL() bool

func (*Bridge) GetShowAllMail

func (bridge *Bridge) GetShowAllMail() bool

func (*Bridge) GetTelemetryDisabled added in v3.2.0

func (bridge *Bridge) GetTelemetryDisabled() bool

func (*Bridge) GetUpdateChannel

func (bridge *Bridge) GetUpdateChannel() updater.Channel

func (*Bridge) GetUpdateRollout added in v3.2.0

func (bridge *Bridge) GetUpdateRollout() float64

func (*Bridge) GetUserIDs

func (bridge *Bridge) GetUserIDs() []string

GetUserIDs returns the IDs of all known users (authorized or not).

func (*Bridge) GetUserInfo

func (bridge *Bridge) GetUserInfo(userID string) (UserInfo, error)

GetUserInfo returns info about the given user.

func (*Bridge) HasUser added in v3.0.9

func (bridge *Bridge) HasUser(userID string) bool

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 *Bridge) IsTelemetryAvailable(ctx context.Context) bool

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

func (bridge *Bridge) LogoutUser(ctx context.Context, userID string) error

LogoutUser logs out the given user.

func (*Bridge) PushError

func (bridge *Bridge) PushError(err error)

func (*Bridge) QueryUserInfo

func (bridge *Bridge) QueryUserInfo(query string) (UserInfo, error)

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 *Bridge) SendHeartbeat(ctx context.Context, heartbeat *telemetry.HeartbeatData) bool

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 *Bridge) SetAutoUpdate(autoUpdate bool) error

func (*Bridge) SetAutostart

func (bridge *Bridge) SetAutostart(autostart bool) error

func (*Bridge) SetBridgeTLSCertPath added in v3.1.0

func (bridge *Bridge) SetBridgeTLSCertPath(certPath, keyPath string) error

func (*Bridge) SetColorScheme

func (bridge *Bridge) SetColorScheme(colorScheme string) error

func (*Bridge) SetCurrentPlatform

func (bridge *Bridge) SetCurrentPlatform(platform string)

func (*Bridge) SetGluonDir

func (bridge *Bridge) SetGluonDir(ctx context.Context, newGluonDir string) error

func (*Bridge) SetIMAPPort

func (bridge *Bridge) SetIMAPPort(ctx context.Context, newPort int) error

func (*Bridge) SetIMAPSSL

func (bridge *Bridge) SetIMAPSSL(ctx context.Context, newSSL bool) error

func (*Bridge) SetKeychainApp

func (bridge *Bridge) SetKeychainApp(helper string) error

func (*Bridge) SetLastHeartbeatSent added in v3.2.0

func (bridge *Bridge) SetLastHeartbeatSent(timestamp time.Time) error

func (*Bridge) SetProxyAllowed

func (bridge *Bridge) SetProxyAllowed(allowed bool) error

func (*Bridge) SetSMTPPort

func (bridge *Bridge) SetSMTPPort(ctx context.Context, newPort int) error

func (*Bridge) SetSMTPSSL

func (bridge *Bridge) SetSMTPSSL(ctx context.Context, newSSL bool) error

func (*Bridge) SetShowAllMail

func (bridge *Bridge) SetShowAllMail(show bool) error

func (*Bridge) SetTelemetryDisabled added in v3.2.0

func (bridge *Bridge) SetTelemetryDisabled(isDisabled bool) error

func (*Bridge) SetUpdateChannel

func (bridge *Bridge) SetUpdateChannel(channel updater.Channel) error

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)
}

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
}

func NewMocks

func NewMocks(tb testing.TB, version, minAuto *semver.Version) *Mocks

func (*Mocks) Close

func (mocks *Mocks) Close()

type ProxyController

type ProxyController interface {
	AllowProxy()
	DisallowProxy()
}

type ReportBugReq added in v3.7.0

type ReportBugReq struct {
	OSType      string
	OSVersion   string
	Title       string
	Description string
	Username    string
	Email       string
	EmailClient string
	IncludeLogs bool
}

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) Cookies

func (j *TestCookieJar) Cookies(u *url.URL) []*http.Cookie

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
}

type UserState

type UserState int
const (
	SignedOut UserState = iota
	Locked
	Connected
)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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