mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
fix: correct timeouts according to spec
This commit is contained in:
committed by
Michal Horejsek
parent
68d2591c73
commit
2db1b113e0
@ -245,6 +245,10 @@ func (cm *ClientManager) switchToReachableServer() (proxy string, err error) {
|
||||
if cm.host == rootURL {
|
||||
go func() {
|
||||
<-time.After(cm.proxyUseDuration)
|
||||
|
||||
cm.hostLocker.Lock()
|
||||
defer cm.hostLocker.Unlock()
|
||||
|
||||
cm.host = rootURL
|
||||
}()
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ func NewBasicTLSDialer() *BasicTLSDialer {
|
||||
|
||||
// DialTLS returns a connection to the given address using the given network.
|
||||
func (b *BasicTLSDialer) DialTLS(network, address string) (conn net.Conn, err error) {
|
||||
dialer := &net.Dialer{Timeout: 10 * time.Second}
|
||||
dialer := &net.Dialer{Timeout: 30 * time.Second} // Alternative Routes spec says this should be a 30s timeout.
|
||||
|
||||
var tlsConfig *tls.Config = nil
|
||||
|
||||
|
||||
@ -30,8 +30,8 @@ import (
|
||||
|
||||
const (
|
||||
proxyUseDuration = 24 * time.Hour
|
||||
proxySearchTimeout = 30 * time.Second
|
||||
proxyQueryTimeout = 10 * time.Second
|
||||
proxySearchTimeout = 20 * time.Second
|
||||
proxyQueryTimeout = 20 * time.Second
|
||||
proxyLookupWait = 5 * time.Second
|
||||
proxyQuery = "dMFYGSLTQOJXXI33ONVQWS3BOMNUA.protonpro.xyz"
|
||||
)
|
||||
@ -144,12 +144,12 @@ func (p *proxyProvider) canReach(url string) bool {
|
||||
url = "https://" + url
|
||||
}
|
||||
|
||||
pinningDialer := NewPinningTLSDialer(NewBasicTLSDialer())
|
||||
dialer := NewPinningTLSDialer(NewBasicTLSDialer())
|
||||
|
||||
pinger := resty.New().
|
||||
SetHostURL(url).
|
||||
SetTimeout(p.lookupTimeout).
|
||||
SetTransport(CreateTransportWithDialer(pinningDialer))
|
||||
SetTransport(CreateTransportWithDialer(dialer))
|
||||
|
||||
if _, err := pinger.R().Get("/tests/ping"); err != nil {
|
||||
logrus.WithField("proxy", url).WithError(err).Warn("Failed to ping proxy")
|
||||
|
||||
Reference in New Issue
Block a user