bridge

package
v3.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: GPL-3.0 Imports: 47 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	MaxTotalAttachmentSize  = 7 * (1 << 20)
	MaxCompressedFilesCount = 6
)

Variables

View Source
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

This section is empty.

Types

type Autostarter

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

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

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

func (*Bridge) ConfigureAppleMail

func (bridge *Bridge) ConfigureAppleMail(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) DeleteUser

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

DeleteUser deletes the given user.

func (*Bridge) FactoryReset

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

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

func (bridge *Bridge) GetFirstStartGUI() bool

func (*Bridge) GetGluonDir

func (bridge *Bridge) GetGluonDir() 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) 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) GetUpdateChannel

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

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

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

func (bridge *Bridge) ReportBug(ctx context.Context, osType, osVersion, description, username, email, client string, attachLogs bool) error

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

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

func (*Bridge) SetCurrentPlatform

func (bridge *Bridge) SetCurrentPlatform(platform string)

func (*Bridge) SetFirstStart

func (bridge *Bridge) SetFirstStart(firstStart bool) error

func (*Bridge) SetFirstStartGUI

func (bridge *Bridge) SetFirstStartGUI(firstStart bool) error

func (*Bridge) SetGluonDir

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

func (*Bridge) SetIMAPPort

func (bridge *Bridge) SetIMAPPort(newPort int) error

func (*Bridge) SetIMAPSSL

func (bridge *Bridge) SetIMAPSSL(newSSL bool) error

func (*Bridge) SetKeychainApp

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

func (*Bridge) SetProxyAllowed

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

func (*Bridge) SetSMTPPort

func (bridge *Bridge) SetSMTPPort(newPort int) error

func (*Bridge) SetSMTPSSL

func (bridge *Bridge) SetSMTPSSL(newSSL bool) error

func (*Bridge) SetShowAllMail

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

func (*Bridge) SetUpdateChannel

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

type Identifier

type Identifier interface {
	GetUserAgent() string
	HasClient() bool
	SetClient(name, version string)
	SetPlatform(platform string)
}

type Locator

type Locator interface {
	ProvideSettingsPath() (string, error)
	ProvideLogsPath() (string, error)
	ProvideGluonPath() (string, error)
	GetLicenseFilePath() string
	GetDependencyLicensesLink() string
	Clear() 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
}

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

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