Other(refactor): Move TLS to Bridge

This commit is contained in:
James Houlahan
2022-08-18 15:34:27 +02:00
committed by Jakub
parent 743a2f8dac
commit 2aaec3b6bd
10 changed files with 101 additions and 68 deletions

View File

@ -21,7 +21,6 @@ package frontend
import (
"github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
"github.com/ProtonMail/proton-bridge/v2/internal/config/tls"
"github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/cli"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/grpc"
@ -45,7 +44,6 @@ func New(
frontendType string,
showWindowOnStart bool,
panicHandler types.PanicHandler,
tls *tls.TLS,
locations *locations.Locations,
settings *settings.Settings,
eventListener listener.Listener,
@ -61,7 +59,6 @@ func New(
return grpc.NewService(
showWindowOnStart,
panicHandler,
tls,
locations,
settings,
eventListener,

View File

@ -28,7 +28,6 @@ import (
"github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/v2/internal/config/settings"
bridgetls "github.com/ProtonMail/proton-bridge/v2/internal/config/tls"
"github.com/ProtonMail/proton-bridge/v2/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/v2/internal/events"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
@ -53,7 +52,6 @@ type Service struct { // nolint:structcheck
eventStreamDoneCh chan struct{}
panicHandler types.PanicHandler
tls *bridgetls.TLS
locations *locations.Locations
settings *settings.Settings
eventListener listener.Listener
@ -77,7 +75,6 @@ type Service struct { // nolint:structcheck
func NewService(
showOnStartup bool,
panicHandler types.PanicHandler,
tls *bridgetls.TLS,
locations *locations.Locations,
settings *settings.Settings,
eventListener listener.Listener,
@ -91,7 +88,6 @@ func NewService(
s := Service{
UnimplementedBridgeServer: UnimplementedBridgeServer{},
panicHandler: panicHandler,
tls: tls,
locations: locations,
settings: settings,
eventListener: eventListener,
@ -111,7 +107,7 @@ func NewService(
// set to 1
s.initializing.Add(1)
config, err := tls.GetConfig()
config, err := bridge.GetTLSConfig()
config.ClientAuth = cryptotls.NoClientCert // skip client auth if the certificate allow it.
if err != nil {
s.log.WithError(err).Error("could not get TLS config")

View File

@ -19,6 +19,8 @@
package types
import (
"crypto/tls"
"github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/v2/internal/updater"
"github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
@ -77,6 +79,10 @@ type User interface {
type Bridger interface {
UserManager
GetTLSConfig() (*tls.Config, error)
// -- old --
ReportBug(osType, osVersion, description, accountName, address, emailClient string, attachLogs bool) error
SetProxyAllowed(bool)
GetProxyAllowed() bool