Other: Add v2 to module name

This commit is contained in:
James Houlahan
2022-05-31 15:54:04 +02:00
parent 098956b81a
commit 4edf2eb92c
230 changed files with 696 additions and 642 deletions

View File

@ -23,7 +23,7 @@ BUILD_TIME:=$(shell date +%FT%T%z)
BUILD_FLAGS:=-tags='${BUILD_TAGS}' BUILD_FLAGS:=-tags='${BUILD_TAGS}'
BUILD_FLAGS_LAUNCHER:=${BUILD_FLAGS} BUILD_FLAGS_LAUNCHER:=${BUILD_FLAGS}
BUILD_FLAGS_GUI:=-tags='${BUILD_TAGS} build_qt' BUILD_FLAGS_GUI:=-tags='${BUILD_TAGS} build_qt'
GO_LDFLAGS:=$(addprefix -X github.com/ProtonMail/proton-bridge/internal/constants.,Version=${APP_VERSION} Revision=${REVISION} BuildTime=${BUILD_TIME}) GO_LDFLAGS:=$(addprefix -X github.com/ProtonMail/proton-bridge/v2/internal/constants.,Version=${APP_VERSION} Revision=${REVISION} BuildTime=${BUILD_TIME})
ifneq "${BUILD_LDFLAGS}" "" ifneq "${BUILD_LDFLAGS}" ""
GO_LDFLAGS+=${BUILD_LDFLAGS} GO_LDFLAGS+=${BUILD_LDFLAGS}
endif endif
@ -228,12 +228,12 @@ integration-test-bridge:
${MAKE} -C test test-bridge ${MAKE} -C test test-bridge
mocks: mocks:
mockgen --package mocks github.com/ProtonMail/proton-bridge/internal/users Locator,PanicHandler,CredentialsStorer,StoreMaker > internal/users/mocks/mocks.go mockgen --package mocks github.com/ProtonMail/proton-bridge/v2/internal/users Locator,PanicHandler,CredentialsStorer,StoreMaker > internal/users/mocks/mocks.go
mockgen --package mocks github.com/ProtonMail/proton-bridge/pkg/listener Listener > internal/users/mocks/listener_mocks.go mockgen --package mocks github.com/ProtonMail/proton-bridge/v2/pkg/listener Listener > internal/users/mocks/listener_mocks.go
mockgen --package mocks github.com/ProtonMail/proton-bridge/internal/store PanicHandler,BridgeUser,ChangeNotifier,Storer > internal/store/mocks/mocks.go mockgen --package mocks github.com/ProtonMail/proton-bridge/v2/internal/store PanicHandler,BridgeUser,ChangeNotifier,Storer > internal/store/mocks/mocks.go
mockgen --package mocks github.com/ProtonMail/proton-bridge/pkg/listener Listener > internal/store/mocks/utils_mocks.go mockgen --package mocks github.com/ProtonMail/proton-bridge/v2/pkg/listener Listener > internal/store/mocks/utils_mocks.go
mockgen --package mocks github.com/ProtonMail/proton-bridge/pkg/pmapi Client,Manager > pkg/pmapi/mocks/mocks.go mockgen --package mocks github.com/ProtonMail/proton-bridge/v2/pkg/pmapi Client,Manager > pkg/pmapi/mocks/mocks.go
mockgen --package mocks github.com/ProtonMail/proton-bridge/pkg/message Fetcher > pkg/message/mocks/mocks.go mockgen --package mocks github.com/ProtonMail/proton-bridge/v2/pkg/message Fetcher > pkg/message/mocks/mocks.go
lint: gofiles lint-golang lint-license lint-dependencies lint-changelog lint: gofiles lint-golang lint-license lint-dependencies lint-changelog

View File

@ -37,8 +37,8 @@ package main
import ( import (
"os" "os"
"github.com/ProtonMail/proton-bridge/internal/app/base" "github.com/ProtonMail/proton-bridge/v2/internal/app/base"
"github.com/ProtonMail/proton-bridge/internal/app/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/app/bridge"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -26,14 +26,14 @@ import (
"github.com/Masterminds/semver/v3" "github.com/Masterminds/semver/v3"
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/internal/config/useragent" "github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/constants" "github.com/ProtonMail/proton-bridge/v2/internal/constants"
"github.com/ProtonMail/proton-bridge/internal/crash" "github.com/ProtonMail/proton-bridge/v2/internal/crash"
"github.com/ProtonMail/proton-bridge/internal/locations" "github.com/ProtonMail/proton-bridge/v2/internal/locations"
"github.com/ProtonMail/proton-bridge/internal/logging" "github.com/ProtonMail/proton-bridge/v2/internal/logging"
"github.com/ProtonMail/proton-bridge/internal/sentry" "github.com/ProtonMail/proton-bridge/v2/internal/sentry"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/internal/versioner" "github.com/ProtonMail/proton-bridge/v2/internal/versioner"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/ProtonMail/proton-bridge module github.com/ProtonMail/proton-bridge/v2
go 1.15 go 1.15

View File

@ -25,17 +25,15 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/ProtonMail/proton-bridge/pkg/ports" "github.com/ProtonMail/proton-bridge/v2/pkg/ports"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var log = logrus.WithField("pkg", "api") //nolint:gochecknoglobals
log = logrus.WithField("pkg", "api") //nolint:gochecknoglobals
)
type apiServer struct { type apiServer struct {
host string host string

View File

@ -20,7 +20,7 @@ package api
import ( import (
"net/http" "net/http"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
) )
// httpHandler with Go's Response and Request. // httpHandler with Go's Response and Request.

View File

@ -21,8 +21,8 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
) )
// focusHandler should be called from other instances (attempt to start bridge // focusHandler should be called from other instances (attempt to start bridge

View File

@ -39,24 +39,24 @@ import (
"github.com/Masterminds/semver/v3" "github.com/Masterminds/semver/v3"
"github.com/ProtonMail/go-autostart" "github.com/ProtonMail/go-autostart"
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/internal/api" "github.com/ProtonMail/proton-bridge/v2/internal/api"
"github.com/ProtonMail/proton-bridge/internal/config/cache" "github.com/ProtonMail/proton-bridge/v2/internal/config/cache"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/config/tls" "github.com/ProtonMail/proton-bridge/v2/internal/config/tls"
"github.com/ProtonMail/proton-bridge/internal/config/useragent" "github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/constants" "github.com/ProtonMail/proton-bridge/v2/internal/constants"
"github.com/ProtonMail/proton-bridge/internal/cookies" "github.com/ProtonMail/proton-bridge/v2/internal/cookies"
"github.com/ProtonMail/proton-bridge/internal/crash" "github.com/ProtonMail/proton-bridge/v2/internal/crash"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/internal/locations" "github.com/ProtonMail/proton-bridge/v2/internal/locations"
"github.com/ProtonMail/proton-bridge/internal/logging" "github.com/ProtonMail/proton-bridge/v2/internal/logging"
"github.com/ProtonMail/proton-bridge/internal/sentry" "github.com/ProtonMail/proton-bridge/v2/internal/sentry"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/internal/users/credentials" "github.com/ProtonMail/proton-bridge/v2/internal/users/credentials"
"github.com/ProtonMail/proton-bridge/internal/versioner" "github.com/ProtonMail/proton-bridge/v2/internal/versioner"
"github.com/ProtonMail/proton-bridge/pkg/keychain" "github.com/ProtonMail/proton-bridge/v2/pkg/keychain"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/allan-simon/go-singleinstance" "github.com/allan-simon/go-singleinstance"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"

View File

@ -21,8 +21,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/ProtonMail/proton-bridge/internal/constants" "github.com/ProtonMail/proton-bridge/v2/internal/constants"
"github.com/ProtonMail/proton-bridge/internal/locations" "github.com/ProtonMail/proton-bridge/v2/internal/locations"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -24,8 +24,8 @@ import (
"runtime" "runtime"
"strings" "strings"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/pkg/keychain" "github.com/ProtonMail/proton-bridge/v2/pkg/keychain"
"github.com/hashicorp/go-multierror" "github.com/hashicorp/go-multierror"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -25,7 +25,7 @@ import (
) )
func TestIncrementRestartFlag(t *testing.T) { func TestIncrementRestartFlag(t *testing.T) {
var tests = []struct { tests := []struct {
in []string in []string
out []string out []string
}{ }{

View File

@ -22,20 +22,20 @@ import (
"crypto/tls" "crypto/tls"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/api" "github.com/ProtonMail/proton-bridge/v2/internal/api"
"github.com/ProtonMail/proton-bridge/internal/app/base" "github.com/ProtonMail/proton-bridge/v2/internal/app/base"
pkgBridge "github.com/ProtonMail/proton-bridge/internal/bridge" pkgBridge "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
pkgTLS "github.com/ProtonMail/proton-bridge/internal/config/tls" pkgTLS "github.com/ProtonMail/proton-bridge/v2/internal/config/tls"
"github.com/ProtonMail/proton-bridge/internal/constants" "github.com/ProtonMail/proton-bridge/v2/internal/constants"
"github.com/ProtonMail/proton-bridge/internal/frontend" "github.com/ProtonMail/proton-bridge/v2/internal/frontend"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/internal/imap" "github.com/ProtonMail/proton-bridge/v2/internal/imap"
"github.com/ProtonMail/proton-bridge/internal/smtp" "github.com/ProtonMail/proton-bridge/v2/internal/smtp"
"github.com/ProtonMail/proton-bridge/internal/store" "github.com/ProtonMail/proton-bridge/v2/internal/store"
"github.com/ProtonMail/proton-bridge/internal/store/cache" "github.com/ProtonMail/proton-bridge/v2/internal/store/cache"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
@ -57,13 +57,16 @@ func New(base *base.Base) *cli.App {
app.Flags = append(app.Flags, []cli.Flag{ app.Flags = append(app.Flags, []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: flagLogIMAP, Name: flagLogIMAP,
Usage: "Enable logging of IMAP communications (all|client|server) (may contain decrypted data!)"}, Usage: "Enable logging of IMAP communications (all|client|server) (may contain decrypted data!)",
},
&cli.BoolFlag{ &cli.BoolFlag{
Name: flagLogSMTP, Name: flagLogSMTP,
Usage: "Enable logging of SMTP communications (may contain decrypted data!)"}, Usage: "Enable logging of SMTP communications (may contain decrypted data!)",
},
&cli.BoolFlag{ &cli.BoolFlag{
Name: flagNonInteractive, Name: flagNonInteractive,
Usage: "Start Bridge entirely noninteractively"}, Usage: "Start Bridge entirely noninteractively",
},
}...) }...)
return app return app
@ -305,7 +308,6 @@ func loadMessageCache(b *base.Base) (cache.Cache, error) {
ConcurrentRead: b.Settings.GetInt(settings.CacheConcurrencyRead), ConcurrentRead: b.Settings.GetInt(settings.CacheConcurrencyRead),
ConcurrentWrite: b.Settings.GetInt(settings.CacheConcurrencyWrite), ConcurrentWrite: b.Settings.GetInt(settings.CacheConcurrencyWrite),
}) })
if err != nil { if err != nil {
return cache.NewInMemoryCache(inMemoryCacheLimnit), err return cache.NewInMemoryCache(inMemoryCacheLimnit), err
} }

View File

@ -18,7 +18,7 @@
// Package bridge provides core functionality of Bridge app. // Package bridge provides core functionality of Bridge app.
package bridge package bridge
import "github.com/ProtonMail/proton-bridge/internal/config/settings" import "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
// IsAutostartEnabled checks if link file exits. // IsAutostartEnabled checks if link file exits.
func (b *Bridge) IsAutostartEnabled() bool { func (b *Bridge) IsAutostartEnabled() bool {

View File

@ -26,17 +26,17 @@ import (
"github.com/Masterminds/semver/v3" "github.com/Masterminds/semver/v3"
"github.com/ProtonMail/go-autostart" "github.com/ProtonMail/go-autostart"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/constants" "github.com/ProtonMail/proton-bridge/v2/internal/constants"
"github.com/ProtonMail/proton-bridge/internal/metrics" "github.com/ProtonMail/proton-bridge/v2/internal/metrics"
"github.com/ProtonMail/proton-bridge/internal/sentry" "github.com/ProtonMail/proton-bridge/v2/internal/sentry"
"github.com/ProtonMail/proton-bridge/internal/store/cache" "github.com/ProtonMail/proton-bridge/v2/internal/store/cache"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/internal/users" "github.com/ProtonMail/proton-bridge/v2/internal/users"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
logrus "github.com/sirupsen/logrus" logrus "github.com/sirupsen/logrus"
) )

View File

@ -28,12 +28,14 @@ import (
"path/filepath" "path/filepath"
"sort" "sort"
"github.com/ProtonMail/proton-bridge/internal/logging" "github.com/ProtonMail/proton-bridge/v2/internal/logging"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
const MaxAttachmentSize = 7 * 1024 * 1024 // 7 MB total limit const (
const MaxCompressedFilesCount = 6 MaxAttachmentSize = 7 * 1024 * 1024 // 7 MB total limit
MaxCompressedFilesCount = 6
)
var ErrSizeTooLarge = errors.New("file is too big") var ErrSizeTooLarge = errors.New("file is too big")

View File

@ -21,12 +21,12 @@ import (
"fmt" "fmt"
"path/filepath" "path/filepath"
"github.com/ProtonMail/proton-bridge/internal/sentry" "github.com/ProtonMail/proton-bridge/v2/internal/sentry"
"github.com/ProtonMail/proton-bridge/internal/store" "github.com/ProtonMail/proton-bridge/v2/internal/store"
"github.com/ProtonMail/proton-bridge/internal/store/cache" "github.com/ProtonMail/proton-bridge/v2/internal/store/cache"
"github.com/ProtonMail/proton-bridge/internal/users" "github.com/ProtonMail/proton-bridge/v2/internal/users"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
) )
type storeFactory struct { type storeFactory struct {

View File

@ -20,7 +20,7 @@ package bridge
import ( import (
"github.com/Masterminds/semver/v3" "github.com/Masterminds/semver/v3"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
) )
type Locator interface { type Locator interface {

View File

@ -22,7 +22,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/ProtonMail/proton-bridge/pkg/files" "github.com/ProtonMail/proton-bridge/v2/pkg/files"
) )
type Cache struct { type Cache struct {
@ -30,7 +30,7 @@ type Cache struct {
} }
func New(dir, version string) (*Cache, error) { func New(dir, version string) (*Cache, error) {
if err := os.MkdirAll(filepath.Join(dir, version), 0700); err != nil { if err := os.MkdirAll(filepath.Join(dir, version), 0o700); err != nil {
return nil, err return nil, err
} }

View File

@ -61,7 +61,7 @@ func TestRemoveOldVersions(t *testing.T) {
func createFilesInDir(t *testing.T, dir string, files ...string) { func createFilesInDir(t *testing.T, dir string, files ...string) {
for _, target := range files { for _, target := range files {
require.NoError(t, os.MkdirAll(filepath.Dir(filepath.Join(dir, target)), 0700)) require.NoError(t, os.MkdirAll(filepath.Dir(filepath.Join(dir, target)), 0o700))
f, err := os.Create(filepath.Join(dir, target)) f, err := os.Create(filepath.Join(dir, target))
require.NoError(t, err) require.NoError(t, err)

View File

@ -79,7 +79,7 @@ func (p *keyValueStore) save() error {
return err return err
} }
return ioutil.WriteFile(p.path, b, 0600) return ioutil.WriteFile(p.path, b, 0o600)
} }
func (p *keyValueStore) setDefault(key, value string) { func (p *keyValueStore) setDefault(key, value string) {

View File

@ -38,7 +38,7 @@ func TestLoadBadKeyValueStore(t *testing.T) {
path, clean := newTmpFile(r) path, clean := newTmpFile(r)
defer clean() defer clean()
r.NoError(ioutil.WriteFile(path, []byte("{\"key\":\"MISSING_QUOTES"), 0700)) r.NoError(ioutil.WriteFile(path, []byte("{\"key\":\"MISSING_QUOTES"), 0o700))
pref := newKeyValueStore(path) pref := newKeyValueStore(path)
r.Equal("", pref.Get("key")) r.Equal("", pref.Get("key"))
} }
@ -131,7 +131,7 @@ func newTestEmptyKeyValueStore(r *require.Assertions) (*keyValueStore, func()) {
func newTestKeyValueStore(r *require.Assertions) (*keyValueStore, func()) { func newTestKeyValueStore(r *require.Assertions) (*keyValueStore, func()) {
path, clean := newTmpFile(r) path, clean := newTmpFile(r)
r.NoError(ioutil.WriteFile(path, []byte("{\"str\":\"value\",\"int\":\"42\",\"bool\":\"true\",\"falseBool\":\"t\"}"), 0700)) r.NoError(ioutil.WriteFile(path, []byte("{\"str\":\"value\",\"int\":\"42\",\"bool\":\"true\",\"falseBool\":\"t\"}"), 0o700))
return newKeyValueStore(path), clean return newKeyValueStore(path), clean
} }

View File

@ -116,7 +116,7 @@ func (t *TLS) GenerateCerts(template *x509.Certificate) error {
return err return err
} }
keyOut, err := os.OpenFile(t.getTLSKeyPath(), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) keyOut, err := os.OpenFile(t.getTLSKeyPath(), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600)
if err != nil { if err != nil {
return err return err
} }

View File

@ -27,7 +27,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
) )
type cookiesByHost map[string][]*http.Cookie type cookiesByHost map[string][]*http.Cookie

View File

@ -24,7 +24,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -19,7 +19,7 @@
package crash package crash
import ( import (
"github.com/ProtonMail/proton-bridge/internal/sentry" "github.com/ProtonMail/proton-bridge/v2/internal/sentry"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -21,7 +21,7 @@ package events
import ( import (
"time" "time"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
) )
// Constants of events used by the event listener in bridge. // Constants of events used by the event listener in bridge.

View File

@ -22,7 +22,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/abiosoft/ishell" "github.com/abiosoft/ishell"
) )

View File

@ -21,9 +21,9 @@ import (
"context" "context"
"strings" "strings"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/abiosoft/ishell" "github.com/abiosoft/ishell"
) )

View File

@ -19,20 +19,18 @@
package cli package cli
import ( import (
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/internal/locations" "github.com/ProtonMail/proton-bridge/v2/internal/locations"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/abiosoft/ishell" "github.com/abiosoft/ishell"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var ( var log = logrus.WithField("pkg", "frontend/cli") //nolint:gochecknoglobals
log = logrus.WithField("pkg", "frontend/cli") //nolint:gochecknoglobals
)
type frontendCLI struct { type frontendCLI struct {
*ishell.Shell *ishell.Shell
@ -70,21 +68,25 @@ func New( //nolint:funlen
} }
// Clear commands. // Clear commands.
clearCmd := &ishell.Cmd{Name: "clear", clearCmd := &ishell.Cmd{
Name: "clear",
Help: "remove stored accounts and preferences. (alias: cl)", Help: "remove stored accounts and preferences. (alias: cl)",
Aliases: []string{"cl"}, Aliases: []string{"cl"},
} }
clearCmd.AddCmd(&ishell.Cmd{Name: "cache", clearCmd.AddCmd(&ishell.Cmd{
Name: "cache",
Help: "remove stored preferences for accounts (aliases: c, prefs, preferences)", Help: "remove stored preferences for accounts (aliases: c, prefs, preferences)",
Aliases: []string{"c", "prefs", "preferences"}, Aliases: []string{"c", "prefs", "preferences"},
Func: fe.deleteCache, Func: fe.deleteCache,
}) })
clearCmd.AddCmd(&ishell.Cmd{Name: "accounts", clearCmd.AddCmd(&ishell.Cmd{
Name: "accounts",
Help: "remove all accounts from keychain. (aliases: a, k, keychain)", Help: "remove all accounts from keychain. (aliases: a, k, keychain)",
Aliases: []string{"a", "k", "keychain"}, Aliases: []string{"a", "k", "keychain"},
Func: fe.deleteAccounts, Func: fe.deleteAccounts,
}) })
clearCmd.AddCmd(&ishell.Cmd{Name: "everything", clearCmd.AddCmd(&ishell.Cmd{
Name: "everything",
Help: "remove everything", Help: "remove everything",
Aliases: []string{"a", "k", "keychain"}, Aliases: []string{"a", "k", "keychain"},
Func: fe.deleteEverything, Func: fe.deleteEverything,
@ -92,22 +94,26 @@ func New( //nolint:funlen
fe.AddCmd(clearCmd) fe.AddCmd(clearCmd)
// Change commands. // Change commands.
changeCmd := &ishell.Cmd{Name: "change", changeCmd := &ishell.Cmd{
Name: "change",
Help: "change server or account settings (aliases: ch, switch)", Help: "change server or account settings (aliases: ch, switch)",
Aliases: []string{"ch", "switch"}, Aliases: []string{"ch", "switch"},
} }
changeCmd.AddCmd(&ishell.Cmd{Name: "mode", changeCmd.AddCmd(&ishell.Cmd{
Name: "mode",
Help: "switch between combined addresses and split addresses mode for account. Use index or account name as parameter. (alias: m)", Help: "switch between combined addresses and split addresses mode for account. Use index or account name as parameter. (alias: m)",
Aliases: []string{"m"}, Aliases: []string{"m"},
Func: fe.changeMode, Func: fe.changeMode,
Completer: fe.completeUsernames, Completer: fe.completeUsernames,
}) })
changeCmd.AddCmd(&ishell.Cmd{Name: "port", changeCmd.AddCmd(&ishell.Cmd{
Name: "port",
Help: "change port numbers of IMAP and SMTP servers. (alias: p)", Help: "change port numbers of IMAP and SMTP servers. (alias: p)",
Aliases: []string{"p"}, Aliases: []string{"p"},
Func: fe.changePort, Func: fe.changePort,
}) })
changeCmd.AddCmd(&ishell.Cmd{Name: "smtp-security", changeCmd.AddCmd(&ishell.Cmd{
Name: "smtp-security",
Help: "change port numbers of IMAP and SMTP servers.(alias: ssl, starttls)", Help: "change port numbers of IMAP and SMTP servers.(alias: ssl, starttls)",
Aliases: []string{"ssl", "starttls"}, Aliases: []string{"ssl", "starttls"},
Func: fe.changeSMTPSecurity, Func: fe.changeSMTPSecurity,
@ -115,113 +121,136 @@ func New( //nolint:funlen
fe.AddCmd(changeCmd) fe.AddCmd(changeCmd)
// DoH commands. // DoH commands.
dohCmd := &ishell.Cmd{Name: "proxy", dohCmd := &ishell.Cmd{
Name: "proxy",
Help: "allow or disallow bridge to securely connect to proton via a third party when it is being blocked", Help: "allow or disallow bridge to securely connect to proton via a third party when it is being blocked",
} }
dohCmd.AddCmd(&ishell.Cmd{Name: "allow", dohCmd.AddCmd(&ishell.Cmd{
Name: "allow",
Help: "allow bridge to securely connect to proton via a third party when it is being blocked", Help: "allow bridge to securely connect to proton via a third party when it is being blocked",
Func: fe.allowProxy, Func: fe.allowProxy,
}) })
dohCmd.AddCmd(&ishell.Cmd{Name: "disallow", dohCmd.AddCmd(&ishell.Cmd{
Name: "disallow",
Help: "disallow bridge to securely connect to proton via a third party when it is being blocked", Help: "disallow bridge to securely connect to proton via a third party when it is being blocked",
Func: fe.disallowProxy, Func: fe.disallowProxy,
}) })
fe.AddCmd(dohCmd) fe.AddCmd(dohCmd)
// Cache-On-Disk commands. // Cache-On-Disk commands.
codCmd := &ishell.Cmd{Name: "local-cache", codCmd := &ishell.Cmd{
Name: "local-cache",
Help: "manage the local encrypted message cache", Help: "manage the local encrypted message cache",
} }
codCmd.AddCmd(&ishell.Cmd{Name: "enable", codCmd.AddCmd(&ishell.Cmd{
Name: "enable",
Help: "enable the local cache", Help: "enable the local cache",
Func: fe.enableCacheOnDisk, Func: fe.enableCacheOnDisk,
}) })
codCmd.AddCmd(&ishell.Cmd{Name: "disable", codCmd.AddCmd(&ishell.Cmd{
Name: "disable",
Help: "disable the local cache", Help: "disable the local cache",
Func: fe.disableCacheOnDisk, Func: fe.disableCacheOnDisk,
}) })
codCmd.AddCmd(&ishell.Cmd{Name: "change-location", codCmd.AddCmd(&ishell.Cmd{
Name: "change-location",
Help: "change the location of the local cache", Help: "change the location of the local cache",
Func: fe.setCacheOnDiskLocation, Func: fe.setCacheOnDiskLocation,
}) })
fe.AddCmd(codCmd) fe.AddCmd(codCmd)
// Updates commands. // Updates commands.
updatesCmd := &ishell.Cmd{Name: "updates", updatesCmd := &ishell.Cmd{
Name: "updates",
Help: "manage bridge updates", Help: "manage bridge updates",
} }
updatesCmd.AddCmd(&ishell.Cmd{Name: "check", updatesCmd.AddCmd(&ishell.Cmd{
Name: "check",
Help: "check for Bridge updates", Help: "check for Bridge updates",
Func: fe.checkUpdates, Func: fe.checkUpdates,
}) })
autoUpdatesCmd := &ishell.Cmd{Name: "autoupdates", autoUpdatesCmd := &ishell.Cmd{
Name: "autoupdates",
Help: "manage bridge updates", Help: "manage bridge updates",
} }
updatesCmd.AddCmd(autoUpdatesCmd) updatesCmd.AddCmd(autoUpdatesCmd)
autoUpdatesCmd.AddCmd(&ishell.Cmd{Name: "enable", autoUpdatesCmd.AddCmd(&ishell.Cmd{
Name: "enable",
Help: "automatically keep bridge up to date", Help: "automatically keep bridge up to date",
Func: fe.enableAutoUpdates, Func: fe.enableAutoUpdates,
}) })
autoUpdatesCmd.AddCmd(&ishell.Cmd{Name: "disable", autoUpdatesCmd.AddCmd(&ishell.Cmd{
Name: "disable",
Help: "require bridge to be manually updated", Help: "require bridge to be manually updated",
Func: fe.disableAutoUpdates, Func: fe.disableAutoUpdates,
}) })
updatesChannelCmd := &ishell.Cmd{Name: "channel", updatesChannelCmd := &ishell.Cmd{
Name: "channel",
Help: "switch updates channel", Help: "switch updates channel",
} }
updatesCmd.AddCmd(updatesChannelCmd) updatesCmd.AddCmd(updatesChannelCmd)
updatesChannelCmd.AddCmd(&ishell.Cmd{Name: "early", updatesChannelCmd.AddCmd(&ishell.Cmd{
Name: "early",
Help: "switch to the early-access updates channel", Help: "switch to the early-access updates channel",
Func: fe.selectEarlyChannel, Func: fe.selectEarlyChannel,
}) })
updatesChannelCmd.AddCmd(&ishell.Cmd{Name: "stable", updatesChannelCmd.AddCmd(&ishell.Cmd{
Name: "stable",
Help: "switch to the stable updates channel", Help: "switch to the stable updates channel",
Func: fe.selectStableChannel, Func: fe.selectStableChannel,
}) })
fe.AddCmd(updatesCmd) fe.AddCmd(updatesCmd)
// Print info commands. // Print info commands.
fe.AddCmd(&ishell.Cmd{Name: "log-dir", fe.AddCmd(&ishell.Cmd{
Name: "log-dir",
Help: "print path to directory with logs. (aliases: log, logs)", Help: "print path to directory with logs. (aliases: log, logs)",
Aliases: []string{"log", "logs"}, Aliases: []string{"log", "logs"},
Func: fe.printLogDir, Func: fe.printLogDir,
}) })
fe.AddCmd(&ishell.Cmd{Name: "manual", fe.AddCmd(&ishell.Cmd{
Name: "manual",
Help: "print URL with instructions. (alias: man)", Help: "print URL with instructions. (alias: man)",
Aliases: []string{"man"}, Aliases: []string{"man"},
Func: fe.printManual, Func: fe.printManual,
}) })
fe.AddCmd(&ishell.Cmd{Name: "credits", fe.AddCmd(&ishell.Cmd{
Name: "credits",
Help: "print used resources.", Help: "print used resources.",
Func: fe.printCredits, Func: fe.printCredits,
}) })
// Account commands. // Account commands.
fe.AddCmd(&ishell.Cmd{Name: "list", fe.AddCmd(&ishell.Cmd{
Name: "list",
Help: "print the list of accounts. (aliases: l, ls)", Help: "print the list of accounts. (aliases: l, ls)",
Func: fe.noAccountWrapper(fe.listAccounts), Func: fe.noAccountWrapper(fe.listAccounts),
Aliases: []string{"l", "ls"}, Aliases: []string{"l", "ls"},
}) })
fe.AddCmd(&ishell.Cmd{Name: "info", fe.AddCmd(&ishell.Cmd{
Name: "info",
Help: "print the configuration for account. Use index or account name as parameter. (alias: i)", Help: "print the configuration for account. Use index or account name as parameter. (alias: i)",
Func: fe.noAccountWrapper(fe.showAccountInfo), Func: fe.noAccountWrapper(fe.showAccountInfo),
Completer: fe.completeUsernames, Completer: fe.completeUsernames,
Aliases: []string{"i"}, Aliases: []string{"i"},
}) })
fe.AddCmd(&ishell.Cmd{Name: "login", fe.AddCmd(&ishell.Cmd{
Name: "login",
Help: "login procedure to add or connect account. Optionally use index or account as parameter. (aliases: a, add, con, connect)", Help: "login procedure to add or connect account. Optionally use index or account as parameter. (aliases: a, add, con, connect)",
Func: fe.loginAccount, Func: fe.loginAccount,
Aliases: []string{"add", "a", "con", "connect"}, Aliases: []string{"add", "a", "con", "connect"},
Completer: fe.completeUsernames, Completer: fe.completeUsernames,
}) })
fe.AddCmd(&ishell.Cmd{Name: "logout", fe.AddCmd(&ishell.Cmd{
Name: "logout",
Help: "disconnect the account. Use index or account name as parameter. (aliases: d, disconnect)", Help: "disconnect the account. Use index or account name as parameter. (aliases: d, disconnect)",
Func: fe.noAccountWrapper(fe.logoutAccount), Func: fe.noAccountWrapper(fe.logoutAccount),
Aliases: []string{"d", "disconnect"}, Aliases: []string{"d", "disconnect"},
Completer: fe.completeUsernames, Completer: fe.completeUsernames,
}) })
fe.AddCmd(&ishell.Cmd{Name: "delete", fe.AddCmd(&ishell.Cmd{
Name: "delete",
Help: "remove the account from keychain. Use index or account name as parameter. (aliases: del, rm, remove)", Help: "remove the account from keychain. Use index or account name as parameter. (aliases: del, rm, remove)",
Func: fe.noAccountWrapper(fe.deleteAccount), Func: fe.noAccountWrapper(fe.deleteAccount),
Aliases: []string{"del", "rm", "remove"}, Aliases: []string{"del", "rm", "remove"},
@ -229,7 +258,8 @@ func New( //nolint:funlen
}) })
// System commands. // System commands.
fe.AddCmd(&ishell.Cmd{Name: "restart", fe.AddCmd(&ishell.Cmd{
Name: "restart",
Help: "restart the bridge.", Help: "restart the bridge.",
Func: fe.restart, Func: fe.restart,
}) })

View File

@ -23,14 +23,12 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/pkg/ports" "github.com/ProtonMail/proton-bridge/v2/pkg/ports"
"github.com/abiosoft/ishell" "github.com/abiosoft/ishell"
) )
var ( var currentPort = "" //nolint:gochecknoglobals
currentPort = "" //nolint:gochecknoglobals
)
func (f *frontendCLI) restart(c *ishell.Context) { func (f *frontendCLI) restart(c *ishell.Context) {
if f.yesNoQuestion("Are you sure you want to restart the Bridge") { if f.yesNoQuestion("Are you sure you want to restart the Bridge") {

View File

@ -20,9 +20,9 @@ package cli
import ( import (
"strings" "strings"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/abiosoft/ishell" "github.com/abiosoft/ishell"
) )

View File

@ -20,7 +20,7 @@ package cli
import ( import (
"strings" "strings"
pmapi "github.com/ProtonMail/proton-bridge/pkg/pmapi" pmapi "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/fatih/color" "github.com/fatih/color"
) )
@ -28,9 +28,7 @@ const (
maxInputRepeat = 2 maxInputRepeat = 2
) )
var ( var bold = color.New(color.Bold).SprintFunc() //nolint:gochecknoglobals
bold = color.New(color.Bold).SprintFunc() //nolint:gochecknoglobals
)
func isNotEmpty(val string) bool { func isNotEmpty(val string) bool {
return val != "" return val != ""

View File

@ -22,9 +22,9 @@ package clientconfig
import ( import (
"errors" "errors"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/config/useragent" "github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -29,10 +29,10 @@ import (
"strings" "strings"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/useragent" "github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/pkg/mobileconfig" "github.com/ProtonMail/proton-bridge/v2/pkg/mobileconfig"
) )
const ( const (
@ -107,7 +107,7 @@ func saveConfigTemporarily(mc *mobileconfig.Config) (fname string, err error) {
// Make sure the file is only readable for the current user. // Make sure the file is only readable for the current user.
fname = filepath.Clean(filepath.Join(dir, "protonmail.mobileconfig")) fname = filepath.Clean(filepath.Join(dir, "protonmail.mobileconfig"))
f, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE, 0600) f, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE, 0o600)
if err != nil { if err != nil {
return return
} }

View File

@ -19,15 +19,15 @@
package frontend package frontend
import ( import (
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/config/useragent" "github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/frontend/cli" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/cli"
"github.com/ProtonMail/proton-bridge/internal/frontend/qt" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/qt"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/internal/locations" "github.com/ProtonMail/proton-bridge/v2/internal/locations"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
) )
type Frontend interface { type Frontend interface {

View File

@ -836,7 +836,7 @@ Window {
property url logsPath: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0] property url logsPath: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
property url licensePath: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0] property url licensePath: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
property url releaseNotesLink: Qt.resolvedUrl("https://protonmail.com/download/bridge/early_releases.html") property url releaseNotesLink: Qt.resolvedUrl("https://protonmail.com/download/bridge/early_releases.html")
property url dependencyLicensesLink: Qt.resolvedUrl("https://github.com/ProtonMail/proton-bridge/blob/master/COPYING_NOTES.md#dependencies") property url dependencyLicensesLink: Qt.resolvedUrl("https://github.com/ProtonMail/proton-bridge/v2/blob/master/COPYING_NOTES.md#dependencies")
property url landingPageLink: Qt.resolvedUrl("https://protonmail.com/bridge") property url landingPageLink: Qt.resolvedUrl("https://protonmail.com/bridge")
property string colorSchemeName: "light" property string colorSchemeName: "light"

View File

@ -8,7 +8,7 @@
id="svg84" id="svg84"
sodipodi:docname="img-welcome-dark.svg" sodipodi:docname="img-welcome-dark.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)" inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)"
inkscape:export-filename="/home/dev/gopath/src/github.com/ProtonMail/proton-bridge/internal/frontend/qml/icons/img-welcome.png" inkscape:export-filename="/home/dev/gopath/src/github.com/ProtonMail/proton-bridge/v2/internal/frontend/qml/icons/img-welcome.png"
inkscape:export-xdpi="400" inkscape:export-xdpi="400"
inkscape:export-ydpi="400" inkscape:export-ydpi="400"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -8,7 +8,7 @@
id="svg84" id="svg84"
sodipodi:docname="img-welcome.svg" sodipodi:docname="img-welcome.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)" inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)"
inkscape:export-filename="/home/dev/gopath/src/github.com/ProtonMail/proton-bridge/internal/frontend/qml/icons/img-welcome.png" inkscape:export-filename="/home/dev/gopath/src/github.com/ProtonMail/proton-bridge/v2/internal/frontend/qml/icons/img-welcome.png"
inkscape:export-xdpi="400" inkscape:export-xdpi="400"
inkscape:export-ydpi="400" inkscape:export-ydpi="400"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -15,8 +15,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>. // along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
// +build darwin //go:build darwin && build_qt
// +build build_qt // +build darwin,build_qt
package dockicon package dockicon
@ -28,6 +28,7 @@ import "C"
func SetDockIconVisibleState(visible bool) { func SetDockIconVisibleState(visible bool) {
C.SetDockIconVisibleState(C.bool(visible)) C.SetDockIconVisibleState(C.bool(visible))
} }
func GetDockIconVisibleState() bool { func GetDockIconVisibleState() bool {
return bool(C.GetDockIconVisibleState()) return bool(C.GetDockIconVisibleState())
} }

View File

@ -15,12 +15,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>. // along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
// +build !darwin //go:build !darwin && build_qt
// +build build_qt // +build !darwin,build_qt
package dockicon package dockicon
func SetDockIconVisibleState(visible bool) {} func SetDockIconVisibleState(visible bool) {}
func GetDockIconVisibleState() bool { func GetDockIconVisibleState() bool {
return true return true
} }

View File

@ -25,13 +25,13 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/config/useragent" "github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/internal/locations" "github.com/ProtonMail/proton-bridge/v2/internal/locations"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
"github.com/therecipe/qt/qml" "github.com/therecipe/qt/qml"

View File

@ -24,9 +24,9 @@ package qt
import ( import (
"strings" "strings"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/pkg/keychain" "github.com/ProtonMail/proton-bridge/v2/pkg/keychain"
) )
func (f *FrontendQt) watchEvents() { func (f *FrontendQt) watchEvents() {

View File

@ -26,7 +26,7 @@ import (
"runtime" "runtime"
"github.com/Masterminds/semver/v3" "github.com/Masterminds/semver/v3"
qmlLog "github.com/ProtonMail/proton-bridge/internal/frontend/qt/log" qmlLog "github.com/ProtonMail/proton-bridge/v2/internal/frontend/qt/log"
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
"github.com/therecipe/qt/qml" "github.com/therecipe/qt/qml"
"github.com/therecipe/qt/quickcontrols2" "github.com/therecipe/qt/quickcontrols2"

View File

@ -24,12 +24,12 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/config/useragent" "github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/ProtonMail/proton-bridge/internal/locations" "github.com/ProtonMail/proton-bridge/v2/internal/locations"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -24,11 +24,11 @@ import (
"runtime" "runtime"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/frontend/clientconfig" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/clientconfig"
"github.com/ProtonMail/proton-bridge/internal/frontend/theme" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/theme"
"github.com/ProtonMail/proton-bridge/pkg/keychain" "github.com/ProtonMail/proton-bridge/v2/pkg/keychain"
"github.com/ProtonMail/proton-bridge/pkg/ports" "github.com/ProtonMail/proton-bridge/v2/pkg/ports"
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
) )

View File

@ -23,8 +23,8 @@ package qt
import ( import (
"sync" "sync"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -25,9 +25,9 @@ import (
"encoding/base64" "encoding/base64"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/internal/users" "github.com/ProtonMail/proton-bridge/v2/internal/users"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
func (f *FrontendQt) login(username, password string) { func (f *FrontendQt) login(username, password string) {

View File

@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>. // along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
//go:build build_qt
// +build build_qt // +build build_qt
package qt package qt

View File

@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>. // along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
//go:build build_qt
// +build build_qt // +build build_qt
// Package log redirects QML logs to logrus // Package log redirects QML logs to logrus

View File

@ -23,9 +23,9 @@ package qt
import ( import (
"runtime" "runtime"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
dockIcon "github.com/ProtonMail/proton-bridge/internal/frontend/qt/dockicon" dockIcon "github.com/ProtonMail/proton-bridge/v2/internal/frontend/qt/dockicon"
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
) )

View File

@ -23,8 +23,8 @@ package qt
import ( import (
"sync" "sync"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/internal/frontend/types" "github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
"github.com/therecipe/qt/core" "github.com/therecipe/qt/core"
) )

View File

@ -32,7 +32,6 @@ func detectSystemTheme() Theme {
`SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize`, `SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize`,
registry.QUERY_VALUE, registry.QUERY_VALUE,
) )
if err != nil { if err != nil {
log.WithError(err).Error("Not able to open register") log.WithError(err).Error("Not able to open register")
return Light return Light

View File

@ -19,9 +19,9 @@
package types package types
import ( import (
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/updater" "github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
// PanicHandler is an interface of a type that can be used to gracefully handle panics which occur. // PanicHandler is an interface of a type that can be used to gracefully handle panics which occur.

View File

@ -36,11 +36,11 @@ import (
"sync" "sync"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/internal/users" "github.com/ProtonMail/proton-bridge/v2/internal/users"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/emersion/go-imap" "github.com/emersion/go-imap"
goIMAPBackend "github.com/emersion/go-imap/backend" goIMAPBackend "github.com/emersion/go-imap/backend"
) )

View File

@ -18,9 +18,9 @@
package imap package imap
import ( import (
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/users" "github.com/ProtonMail/proton-bridge/v2/internal/users"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
type cacheProvider interface { type cacheProvider interface {

View File

@ -21,8 +21,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/emersion/go-imap" "github.com/emersion/go-imap"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -27,9 +27,9 @@ import (
"time" "time"
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/internal/imap/uidplus" "github.com/ProtonMail/proton-bridge/v2/internal/imap/uidplus"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/emersion/go-imap" "github.com/emersion/go-imap"
"github.com/emersion/go-message/textproto" "github.com/emersion/go-message/textproto"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -177,7 +177,7 @@ func (im *imapMailbox) labelExistingMessage(msg storeMessageProvider) error { //
// If the message is moved from any folder, the moment when expunge happens on source we will move message trash unless we move it to archive. // If the message is moved from any folder, the moment when expunge happens on source we will move message trash unless we move it to archive.
// If the message is already in Archive we should not call API at all. // If the message is already in Archive we should not call API at all.
// Otherwise the message is already in All mail, Return OK. // Otherwise the message is already in All mail, Return OK.
var storeMBox = im.storeMailbox storeMBox := im.storeMailbox
if pmapi.AllMailLabel == storeMBox.LabelID() { if pmapi.AllMailLabel == storeMBox.LabelID() {
if msg.Message().HasLabelID(pmapi.ArchiveLabel) { if msg.Message().HasLabelID(pmapi.ArchiveLabel) {
return uidplus.AppendResponse(storeMBox.UIDValidity(), storeMBox.GetUIDList([]string{msg.ID()})) return uidplus.AppendResponse(storeMBox.UIDValidity(), storeMBox.GetUIDList([]string{msg.ID()}))
@ -238,7 +238,7 @@ func (im *imapMailbox) importMessage(kr *crypto.KeyRing, hdr textproto.Header, b
return err return err
} }
var targetMailbox = im.storeMailbox targetMailbox := im.storeMailbox
if targetMailbox.LabelID() == pmapi.AllMailLabel { if targetMailbox.LabelID() == pmapi.AllMailLabel {
// Importing mail in directly into All Mail is not allowed. Instead we redirect the import to Archive // Importing mail in directly into All Mail is not allowed. Instead we redirect the import to Archive
// The mail will automatically appear in All mail. The appends response still reports that the mail was // The mail will automatically appear in All mail. The appends response still reports that the mail was

View File

@ -20,7 +20,7 @@ package imap
import ( import (
"bytes" "bytes"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/emersion/go-imap" "github.com/emersion/go-imap"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -21,7 +21,7 @@ import (
"bytes" "bytes"
"strings" "strings"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/emersion/go-imap" "github.com/emersion/go-imap"
) )

View File

@ -24,10 +24,10 @@ import (
"sync" "sync"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/imap/uidplus" "github.com/ProtonMail/proton-bridge/v2/internal/imap/uidplus"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/ProtonMail/proton-bridge/pkg/parallel" "github.com/ProtonMail/proton-bridge/v2/pkg/parallel"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/emersion/go-imap" "github.com/emersion/go-imap"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"

View File

@ -21,7 +21,7 @@ import (
"errors" "errors"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/store" "github.com/ProtonMail/proton-bridge/v2/internal/store"
imap "github.com/emersion/go-imap" imap "github.com/emersion/go-imap"
) )

View File

@ -26,13 +26,13 @@ import (
"time" "time"
imapid "github.com/ProtonMail/go-imap-id" imapid "github.com/ProtonMail/go-imap-id"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/useragent" "github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/imap/id" "github.com/ProtonMail/proton-bridge/v2/internal/imap/id"
"github.com/ProtonMail/proton-bridge/internal/imap/idle" "github.com/ProtonMail/proton-bridge/v2/internal/imap/idle"
"github.com/ProtonMail/proton-bridge/internal/imap/uidplus" "github.com/ProtonMail/proton-bridge/v2/internal/imap/uidplus"
"github.com/ProtonMail/proton-bridge/internal/serverutil" "github.com/ProtonMail/proton-bridge/v2/internal/serverutil"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/emersion/go-imap" "github.com/emersion/go-imap"
imapappendlimit "github.com/emersion/go-imap-appendlimit" imapappendlimit "github.com/emersion/go-imap-appendlimit"
imapmove "github.com/emersion/go-imap-move" imapmove "github.com/emersion/go-imap-move"

View File

@ -23,10 +23,10 @@ import (
"net/textproto" "net/textproto"
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/internal/imap/uidplus" "github.com/ProtonMail/proton-bridge/v2/internal/imap/uidplus"
"github.com/ProtonMail/proton-bridge/internal/store" "github.com/ProtonMail/proton-bridge/v2/internal/store"
pkgMsg "github.com/ProtonMail/proton-bridge/pkg/message" pkgMsg "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
type storeUserProvider interface { type storeUserProvider interface {

View File

@ -22,9 +22,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/store" "github.com/ProtonMail/proton-bridge/v2/internal/store"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
imap "github.com/emersion/go-imap" imap "github.com/emersion/go-imap"
goIMAPBackend "github.com/emersion/go-imap/backend" goIMAPBackend "github.com/emersion/go-imap/backend"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"

View File

@ -22,7 +22,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
imapquota "github.com/emersion/go-imap-quota" imapquota "github.com/emersion/go-imap-quota"
goIMAPBackend "github.com/emersion/go-imap/backend" goIMAPBackend "github.com/emersion/go-imap/backend"
) )

View File

@ -24,7 +24,7 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"github.com/ProtonMail/proton-bridge/pkg/files" "github.com/ProtonMail/proton-bridge/v2/pkg/files"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -107,13 +107,13 @@ func (l *Locations) getLicenseFilePath() string {
// GetDependencyLicensesLink returns link to page listing dependencies. // GetDependencyLicensesLink returns link to page listing dependencies.
func (l *Locations) GetDependencyLicensesLink() string { func (l *Locations) GetDependencyLicensesLink() string {
return "https://github.com/ProtonMail/proton-bridge/blob/master/COPYING_NOTES.md#dependencies" return "https://github.com/ProtonMail/proton-bridge/v2/blob/master/COPYING_NOTES.md#dependencies"
} }
// ProvideSettingsPath returns a location for user settings (e.g. ~/.config/<company>/<app>). // ProvideSettingsPath returns a location for user settings (e.g. ~/.config/<company>/<app>).
// It creates it if it doesn't already exist. // It creates it if it doesn't already exist.
func (l *Locations) ProvideSettingsPath() (string, error) { func (l *Locations) ProvideSettingsPath() (string, error) {
if err := os.MkdirAll(l.getSettingsPath(), 0700); err != nil { if err := os.MkdirAll(l.getSettingsPath(), 0o700); err != nil {
return "", err return "", err
} }
@ -123,7 +123,7 @@ func (l *Locations) ProvideSettingsPath() (string, error) {
// ProvideLogsPath returns a location for user logs (e.g. ~/.cache/<company>/<app>/logs). // ProvideLogsPath returns a location for user logs (e.g. ~/.cache/<company>/<app>/logs).
// It creates it if it doesn't already exist. // It creates it if it doesn't already exist.
func (l *Locations) ProvideLogsPath() (string, error) { func (l *Locations) ProvideLogsPath() (string, error) {
if err := os.MkdirAll(l.getLogsPath(), 0700); err != nil { if err := os.MkdirAll(l.getLogsPath(), 0o700); err != nil {
return "", err return "", err
} }
@ -133,7 +133,7 @@ func (l *Locations) ProvideLogsPath() (string, error) {
// ProvideCachePath returns a location for user cache dirs (e.g. ~/.config/<company>/<app>/cache). // ProvideCachePath returns a location for user cache dirs (e.g. ~/.config/<company>/<app>/cache).
// It creates it if it doesn't already exist. // It creates it if it doesn't already exist.
func (l *Locations) ProvideCachePath() (string, error) { func (l *Locations) ProvideCachePath() (string, error) {
if err := os.MkdirAll(l.getCachePath(), 0700); err != nil { if err := os.MkdirAll(l.getCachePath(), 0o700); err != nil {
return "", err return "", err
} }
@ -148,7 +148,7 @@ func (l *Locations) GetOldCachePath() string {
// ProvideUpdatesPath returns a location for update files (e.g. ~/.cache/<company>/<app>/updates). // ProvideUpdatesPath returns a location for update files (e.g. ~/.cache/<company>/<app>/updates).
// It creates it if it doesn't already exist. // It creates it if it doesn't already exist.
func (l *Locations) ProvideUpdatesPath() (string, error) { func (l *Locations) ProvideUpdatesPath() (string, error) {
if err := os.MkdirAll(l.getUpdatesPath(), 0700); err != nil { if err := os.MkdirAll(l.getUpdatesPath(), 0o700); err != nil {
return "", err return "", err
} }

View File

@ -161,7 +161,7 @@ func newTestLocations(t *testing.T) *Locations {
func createFilesInDir(t *testing.T, dir string, files ...string) { func createFilesInDir(t *testing.T, dir string, files ...string) {
for _, target := range files { for _, target := range files {
require.NoError(t, os.MkdirAll(filepath.Dir(filepath.Join(dir, target)), 0700)) require.NoError(t, os.MkdirAll(filepath.Dir(filepath.Join(dir, target)), 0o700))
f, err := os.Create(filepath.Join(dir, target)) f, err := os.Create(filepath.Join(dir, target))
require.NoError(t, err) require.NoError(t, err)

View File

@ -25,8 +25,8 @@ import (
"runtime/pprof" "runtime/pprof"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/constants" "github.com/ProtonMail/proton-bridge/v2/internal/constants"
"github.com/ProtonMail/proton-bridge/internal/crash" "github.com/ProtonMail/proton-bridge/v2/internal/crash"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -34,7 +34,7 @@ func DumpStackTrace(logsPath string) crash.RecoveryAction {
return func(r interface{}) error { return func(r interface{}) error {
file := filepath.Join(logsPath, getStackTraceName(constants.Version, constants.Revision)) file := filepath.Join(logsPath, getStackTraceName(constants.Version, constants.Revision))
f, err := os.OpenFile(filepath.Clean(file), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0600) f, err := os.OpenFile(filepath.Clean(file), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0o600)
if err != nil { if err != nil {
return err return err
} }

View File

@ -25,7 +25,7 @@ import (
"regexp" "regexp"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/constants" "github.com/ProtonMail/proton-bridge/v2/internal/constants"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/writer" "github.com/sirupsen/logrus/hooks/writer"
) )

View File

@ -30,11 +30,11 @@ func TestClearLogs(t *testing.T) {
dir, err := ioutil.TempDir("", "clear-logs-test") dir, err := ioutil.TempDir("", "clear-logs-test")
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "other.log"), []byte("Hello"), 0755)) require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "other.log"), []byte("Hello"), 0o755))
require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "v1_10.log"), []byte("Hello"), 0755)) require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "v1_10.log"), []byte("Hello"), 0o755))
require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "v1_11.log"), []byte("Hello"), 0755)) require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "v1_11.log"), []byte("Hello"), 0o755))
require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "v2_12.log"), []byte("Hello"), 0755)) require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "v2_12.log"), []byte("Hello"), 0o755))
require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "v2_13.log"), []byte("Hello"), 0755)) require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "v2_13.log"), []byte("Hello"), 0o755))
require.NoError(t, clearLogs(dir, 3, 0)) require.NoError(t, clearLogs(dir, 3, 0))
checkFileNames(t, dir, []string{ checkFileNames(t, dir, []string{

View File

@ -25,8 +25,8 @@ import (
"runtime" "runtime"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/constants" "github.com/ProtonMail/proton-bridge/v2/internal/constants"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/getsentry/sentry-go" "github.com/getsentry/sentry-go"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -35,30 +35,30 @@ func TestSkipDuringUnwind(t *testing.T) {
}() }()
wantSkippedFunctions := []string{ wantSkippedFunctions := []string{
"github.com/ProtonMail/proton-bridge/internal/sentry.TestSkipDuringUnwind", "github.com/ProtonMail/proton-bridge/v2/internal/sentry.TestSkipDuringUnwind",
"github.com/ProtonMail/proton-bridge/internal/sentry.TestSkipDuringUnwind.func1", "github.com/ProtonMail/proton-bridge/v2/internal/sentry.TestSkipDuringUnwind.func1",
} }
r.Equal(t, wantSkippedFunctions, skippedFunctions) r.Equal(t, wantSkippedFunctions, skippedFunctions)
} }
func TestFilterOutPanicHandlers(t *testing.T) { func TestFilterOutPanicHandlers(t *testing.T) {
skippedFunctions = []string{ skippedFunctions = []string{
"github.com/ProtonMail/proton-bridge/pkg/config.(*PanicHandler).HandlePanic", "github.com/ProtonMail/proton-bridge/v2/pkg/config.(*PanicHandler).HandlePanic",
"github.com/ProtonMail/proton-bridge/pkg/config.HandlePanic", "github.com/ProtonMail/proton-bridge/v2/pkg/config.HandlePanic",
"github.com/ProtonMail/proton-bridge/internal/sentry.ReportSentryCrash", "github.com/ProtonMail/proton-bridge/v2/internal/sentry.ReportSentryCrash",
"github.com/ProtonMail/proton-bridge/internal/sentry.ReportSentryCrash.func1", "github.com/ProtonMail/proton-bridge/v2/internal/sentry.ReportSentryCrash.func1",
} }
frames := []sentry.Frame{ frames := []sentry.Frame{
{Module: "github.com/ProtonMail/proton-bridge/internal/cmd", Function: "main"}, {Module: "github.com/ProtonMail/proton-bridge/v2/internal/cmd", Function: "main"},
{Module: "github.com/urfave/cli", Function: "(*App).Run"}, {Module: "github.com/urfave/cli", Function: "(*App).Run"},
{Module: "github.com/ProtonMail/proton-bridge/internal/cmd", Function: "RegisterHandlePanic"}, {Module: "github.com/ProtonMail/proton-bridge/v2/internal/cmd", Function: "RegisterHandlePanic"},
{Module: "github.com/ProtonMail/pkg", Function: "HandlePanic"}, {Module: "github.com/ProtonMail/pkg", Function: "HandlePanic"},
{Module: "main", Function: "run"}, {Module: "main", Function: "run"},
{Module: "github.com/ProtonMail/proton-bridge/pkg/config", Function: "(*PanicHandler).HandlePanic"}, {Module: "github.com/ProtonMail/proton-bridge/v2/pkg/config", Function: "(*PanicHandler).HandlePanic"},
{Module: "github.com/ProtonMail/proton-bridge/pkg/config", Function: "HandlePanic"}, {Module: "github.com/ProtonMail/proton-bridge/v2/pkg/config", Function: "HandlePanic"},
{Module: "github.com/ProtonMail/proton-bridge/internal/sentry", Function: "ReportSentryCrash"}, {Module: "github.com/ProtonMail/proton-bridge/v2/internal/sentry", Function: "ReportSentryCrash"},
{Module: "github.com/ProtonMail/proton-bridge/internal/sentry", Function: "ReportSentryCrash.func1"}, {Module: "github.com/ProtonMail/proton-bridge/v2/internal/sentry", Function: "ReportSentryCrash.func1"},
} }
gotFrames := filterOutPanicHandlers(frames) gotFrames := filterOutPanicHandlers(frames)

View File

@ -22,8 +22,8 @@ import (
"fmt" "fmt"
"net" "net"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -22,9 +22,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/internal/serverutil" "github.com/ProtonMail/proton-bridge/v2/internal/serverutil"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -24,8 +24,8 @@ import (
"net" "net"
"net/http" "net/http"
"github.com/ProtonMail/proton-bridge/internal/serverutil" "github.com/ProtonMail/proton-bridge/v2/internal/serverutil"
"github.com/ProtonMail/proton-bridge/pkg/ports" "github.com/ProtonMail/proton-bridge/v2/pkg/ports"
) )
func newTestServer() *testServer { func newTestServer() *testServer {

View File

@ -21,11 +21,11 @@ import (
"strings" "strings"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings" "github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/users" "github.com/ProtonMail/proton-bridge/v2/internal/users"
"github.com/ProtonMail/proton-bridge/pkg/confirmer" "github.com/ProtonMail/proton-bridge/v2/pkg/confirmer"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
goSMTPBackend "github.com/emersion/go-smtp" goSMTPBackend "github.com/emersion/go-smtp"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"

View File

@ -18,9 +18,9 @@
package smtp package smtp
import ( import (
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/users" "github.com/ProtonMail/proton-bridge/v2/internal/users"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
type bridger interface { type bridger interface {

View File

@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>. // along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
//go:build build_qa
// +build build_qa // +build build_qa
package smtp package smtp
@ -38,7 +39,7 @@ func dumpMessageData(b []byte, subject string) {
path := filepath.Join(home, "bridge-qa") path := filepath.Join(home, "bridge-qa")
if err := os.MkdirAll(path, 0700); err != nil { if err := os.MkdirAll(path, 0o700); err != nil {
logrus.WithError(err).Error("Failed to dump raw message data") logrus.WithError(err).Error("Failed to dump raw message data")
return return
} }
@ -50,7 +51,7 @@ func dumpMessageData(b []byte, subject string) {
if err := ioutil.WriteFile( if err := ioutil.WriteFile(
filepath.Join(path, fmt.Sprintf("%v-%v.eml", subject, time.Now().Unix())), filepath.Join(path, fmt.Sprintf("%v-%v.eml", subject, time.Now().Unix())),
b, b,
0600, 0o600,
); err != nil { ); err != nil {
logrus.WithError(err).Error("Failed to dump raw message data") logrus.WithError(err).Error("Failed to dump raw message data")
return return

View File

@ -19,7 +19,7 @@ package smtp
import ( import (
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -21,7 +21,7 @@ import (
"testing" "testing"
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -25,7 +25,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
type messageGetter interface { type messageGetter interface {

View File

@ -25,7 +25,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View File

@ -23,9 +23,9 @@ import (
"io" "io"
"net" "net"
"github.com/ProtonMail/proton-bridge/internal/bridge" "github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/serverutil" "github.com/ProtonMail/proton-bridge/v2/internal/serverutil"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/emersion/go-sasl" "github.com/emersion/go-sasl"
goSMTP "github.com/emersion/go-smtp" goSMTP "github.com/emersion/go-smtp"
) )

View File

@ -20,6 +20,4 @@ package smtp
import "github.com/sirupsen/logrus" import "github.com/sirupsen/logrus"
var ( var log = logrus.WithField("pkg", "smtp") //nolint:gochecknoglobals
log = logrus.WithField("pkg", "smtp") //nolint:gochecknoglobals
)

View File

@ -21,7 +21,7 @@ import (
"io" "io"
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
type storeUserProvider interface { type storeUserProvider interface {

View File

@ -32,11 +32,11 @@ import (
"time" "time"
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/internal/events" "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
pkgMsg "github.com/ProtonMail/proton-bridge/pkg/message" pkgMsg "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/ProtonMail/proton-bridge/pkg/message/parser" "github.com/ProtonMail/proton-bridge/v2/pkg/message/parser"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
goSMTPBackend "github.com/emersion/go-smtp" goSMTPBackend "github.com/emersion/go-smtp"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"

View File

@ -23,7 +23,7 @@ import (
"strings" "strings"
"github.com/ProtonMail/go-vcard" "github.com/ProtonMail/go-vcard"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
type ContactMetadata struct { type ContactMetadata struct {

View File

@ -18,7 +18,7 @@
package store package store
import ( import (
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
bolt "go.etcd.io/bbolt" bolt "go.etcd.io/bbolt"
) )

View File

@ -20,7 +20,7 @@ package store
import ( import (
"fmt" "fmt"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
// ListMailboxes returns all mailboxes. // ListMailboxes returns all mailboxes.

View File

@ -18,7 +18,7 @@
package store package store
import ( import (
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
bolt "go.etcd.io/bbolt" bolt "go.etcd.io/bbolt"
) )

View File

@ -21,9 +21,9 @@ import (
"context" "context"
"github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/ProtonMail/gopenpgp/v2/crypto"
"github.com/ProtonMail/proton-bridge/internal/store/cache" "github.com/ProtonMail/proton-bridge/v2/internal/store/cache"
"github.com/ProtonMail/proton-bridge/pkg/message" "github.com/ProtonMail/proton-bridge/v2/pkg/message"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
bolt "go.etcd.io/bbolt" bolt "go.etcd.io/bbolt"
) )

View File

@ -29,12 +29,14 @@ import (
"path/filepath" "path/filepath"
"sync" "sync"
"github.com/ProtonMail/proton-bridge/pkg/semaphore" "github.com/ProtonMail/proton-bridge/v2/pkg/semaphore"
"github.com/ricochet2200/go-disk-usage/du" "github.com/ricochet2200/go-disk-usage/du"
) )
var ErrMsgCorrupted = errors.New("ecrypted file was corrupted") var (
var ErrLowSpace = errors.New("not enough free space left on device") ErrMsgCorrupted = errors.New("ecrypted file was corrupted")
ErrLowSpace = errors.New("not enough free space left on device")
)
// IsOnDiskCache will return true if Cache is type of onDiskCache. // IsOnDiskCache will return true if Cache is type of onDiskCache.
func IsOnDiskCache(c Cache) bool { func IsOnDiskCache(c Cache) bool {
@ -58,7 +60,7 @@ type onDiskCache struct {
} }
func NewOnDiskCache(path string, cmp Compressor, opts Options) (Cache, error) { func NewOnDiskCache(path string, cmp Compressor, opts Options) (Cache, error) {
if err := os.MkdirAll(path, 0700); err != nil { if err := os.MkdirAll(path, 0o700); err != nil {
return nil, err return nil, err
} }
@ -114,7 +116,7 @@ func (c *onDiskCache) Unlock(userID string, passphrase []byte) error {
return err return err
} }
if err := os.MkdirAll(c.getUserPath(userID), 0700); err != nil { if err := os.MkdirAll(c.getUserPath(userID), 0o700); err != nil {
return err return err
} }
@ -239,7 +241,7 @@ func (c *onDiskCache) writeFile(path string, b []byte) error {
defer c.update() defer c.update()
// NOTE(GODT-1158): What happens when this fails? Should be fixed eventually. // NOTE(GODT-1158): What happens when this fails? Should be fixed eventually.
return ioutil.WriteFile(filepath.Clean(path), b, 0600) return ioutil.WriteFile(filepath.Clean(path), b, 0o600)
} }
func (c *onDiskCache) hasSpace(size int) bool { func (c *onDiskCache) hasSpace(size int) bool {

View File

@ -20,7 +20,7 @@ package store
import ( import (
"testing" "testing"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -21,7 +21,7 @@ import (
"context" "context"
"time" "time"
"github.com/ProtonMail/proton-bridge/internal/store/cache" "github.com/ProtonMail/proton-bridge/v2/internal/store/cache"
) )
func (store *Store) StartWatcher() { func (store *Store) StartWatcher() {

View File

@ -20,7 +20,7 @@ package store
import ( import (
"testing" "testing"
storemocks "github.com/ProtonMail/proton-bridge/internal/store/mocks" storemocks "github.com/ProtonMail/proton-bridge/v2/internal/store/mocks"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -18,7 +18,7 @@
package store package store
import ( import (
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
) )
type ChangeNotifier interface { type ChangeNotifier interface {

View File

@ -20,7 +20,7 @@ package store
import ( import (
"testing" "testing"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -22,9 +22,9 @@ import (
"math/rand" "math/rand"
"time" "time"
bridgeEvents "github.com/ProtonMail/proton-bridge/internal/events" bridgeEvents "github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/pkg/listener" "github.com/ProtonMail/proton-bridge/v2/pkg/listener"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )

View File

@ -23,7 +23,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -23,7 +23,7 @@ import (
"strings" "strings"
"sync/atomic" "sync/atomic"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
bolt "go.etcd.io/bbolt" bolt "go.etcd.io/bbolt"
) )

Some files were not shown because too many files have changed in this diff Show More