GODT-1388: Refactor Alternative routing
This commit is contained in:
parent
af0c5e6bae
commit
42ced6694e
|
@ -223,3 +223,19 @@ func (b *Bridge) MigrateCache(from, to string) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetProxyAllowed instructs the app whether to use DoH to access an API proxy if necessary.
|
||||
// It also needs to work before the app is initialised (because we may need to use the proxy at startup).
|
||||
func (b *Bridge) SetProxyAllowed(proxyAllowed bool) {
|
||||
b.settings.SetBool(settings.AllowProxyKey, proxyAllowed)
|
||||
if proxyAllowed {
|
||||
b.clientManager.AllowProxy()
|
||||
} else {
|
||||
b.clientManager.DisallowProxy()
|
||||
}
|
||||
}
|
||||
|
||||
// GetProxyAllowed returns whether use of DoH is enabled to access an API proxy if necessary.
|
||||
func (b *Bridge) GetProxyAllowed() bool {
|
||||
return b.settings.GetBool(settings.AllowProxyKey)
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ func (f *frontendCLI) changePort(c *ishell.Context) {
|
|||
}
|
||||
|
||||
func (f *frontendCLI) allowProxy(c *ishell.Context) {
|
||||
if f.settings.GetBool(settings.AllowProxyKey) {
|
||||
if f.bridge.GetProxyAllowed() {
|
||||
f.Println("Bridge is already set to use alternative routing to connect to Proton if it is being blocked.")
|
||||
return
|
||||
}
|
||||
|
@ -137,13 +137,12 @@ func (f *frontendCLI) allowProxy(c *ishell.Context) {
|
|||
f.Println("Bridge is currently set to NOT use alternative routing to connect to Proton if it is being blocked.")
|
||||
|
||||
if f.yesNoQuestion("Are you sure you want to allow bridge to do this") {
|
||||
f.settings.SetBool(settings.AllowProxyKey, true)
|
||||
f.bridge.AllowProxy()
|
||||
f.bridge.SetProxyAllowed(true)
|
||||
}
|
||||
}
|
||||
|
||||
func (f *frontendCLI) disallowProxy(c *ishell.Context) {
|
||||
if !f.settings.GetBool(settings.AllowProxyKey) {
|
||||
if !f.bridge.GetProxyAllowed() {
|
||||
f.Println("Bridge is already set to NOT use alternative routing to connect to Proton if it is being blocked.")
|
||||
return
|
||||
}
|
||||
|
@ -151,8 +150,7 @@ func (f *frontendCLI) disallowProxy(c *ishell.Context) {
|
|||
f.Println("Bridge is currently set to use alternative routing to connect to Proton if it is being blocked.")
|
||||
|
||||
if f.yesNoQuestion("Are you sure you want to stop bridge from doing this") {
|
||||
f.settings.SetBool(settings.AllowProxyKey, false)
|
||||
f.bridge.DisallowProxy()
|
||||
f.bridge.SetProxyAllowed(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,12 +99,8 @@ func (f *FrontendQt) toggleAutostart(makeItEnabled bool) {
|
|||
}
|
||||
|
||||
func (f *FrontendQt) toggleDoH(makeItEnabled bool) {
|
||||
if f.settings.GetBool(settings.AllowProxyKey) == makeItEnabled {
|
||||
f.qml.SetIsDoHEnabled(makeItEnabled)
|
||||
return
|
||||
}
|
||||
f.settings.SetBool(settings.AllowProxyKey, makeItEnabled)
|
||||
f.restart()
|
||||
f.bridge.SetProxyAllowed(makeItEnabled)
|
||||
f.qml.SetIsDoHEnabled(f.bridge.GetProxyAllowed())
|
||||
}
|
||||
|
||||
func (f *FrontendQt) toggleUseSSLforSMTP(makeItEnabled bool) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//go:build build_qt
|
||||
// +build build_qt
|
||||
|
||||
package qt
|
||||
|
@ -232,7 +233,7 @@ func (q *QMLBackend) setup(f *FrontendQt) {
|
|||
}()
|
||||
})
|
||||
|
||||
q.SetIsDoHEnabled(f.settings.GetBool(settings.AllowProxyKey))
|
||||
q.SetIsDoHEnabled(f.bridge.GetProxyAllowed())
|
||||
q.ConnectToggleDoH(f.toggleDoH)
|
||||
|
||||
q.SetUseSSLforSMTP(f.settings.GetBool(settings.SMTPSSLKey))
|
||||
|
|
|
@ -75,8 +75,8 @@ type Bridger interface {
|
|||
UserManager
|
||||
|
||||
ReportBug(osType, osVersion, description, accountName, address, emailClient string, attachLogs bool) error
|
||||
AllowProxy()
|
||||
DisallowProxy()
|
||||
SetProxyAllowed(bool)
|
||||
GetProxyAllowed() bool
|
||||
EnableCache() error
|
||||
DisableCache() error
|
||||
MigrateCache(from, to string) error
|
||||
|
|
|
@ -419,18 +419,6 @@ func (u *Users) SendMetric(m metrics.Metric) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// AllowProxy instructs the app to use DoH to access an API proxy if necessary.
|
||||
// It also needs to work before the app is initialised (because we may need to use the proxy at startup).
|
||||
func (u *Users) AllowProxy() {
|
||||
u.clientManager.AllowProxy()
|
||||
}
|
||||
|
||||
// DisallowProxy instructs the app to not use DoH to access an API proxy if necessary.
|
||||
// It also needs to work before the app is initialised (because we may need to use the proxy at startup).
|
||||
func (u *Users) DisallowProxy() {
|
||||
u.clientManager.DisallowProxy()
|
||||
}
|
||||
|
||||
// hasUser returns whether the struct currently has a user with ID `id`.
|
||||
func (u *Users) hasUser(id string) (user *User, ok bool) {
|
||||
for _, u := range u.users {
|
||||
|
|
Loading…
Reference in New Issue