feat(GODT-2500): Reorganise async methods.

This commit is contained in:
Jakub
2023-03-30 17:50:40 +02:00
parent ec92c918cd
commit de5fd07a22
42 changed files with 136 additions and 511 deletions

View File

@ -24,7 +24,7 @@ import (
"sync"
"time"
"github.com/ProtonMail/proton-bridge/v3/internal/async"
"github.com/ProtonMail/gluon/async"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@ -79,12 +79,6 @@ func formatAsAddress(rawURL string) string {
return net.JoinHostPort(host, port)
}
func (d *ProxyTLSDialer) handlePanic() {
if d.panicHandler != nil {
d.panicHandler.HandlePanic()
}
}
// DialTLSContext dials the given network/address. If it fails, it retries using a proxy.
func (d *ProxyTLSDialer) DialTLSContext(ctx context.Context, network, address string) (net.Conn, error) {
d.locker.RLock()
@ -139,7 +133,7 @@ func (d *ProxyTLSDialer) switchToReachableServer() error {
// This means we want to disable it again in 24 hours.
if d.proxyAddress == d.directAddress {
go func() {
defer d.handlePanic()
defer async.HandlePanic(d.panicHandler)
<-time.After(d.proxyUseDuration)