forked from Silverfish/proton-bridge
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 {
|
if cm.host == rootURL {
|
||||||
go func() {
|
go func() {
|
||||||
<-time.After(cm.proxyUseDuration)
|
<-time.After(cm.proxyUseDuration)
|
||||||
|
|
||||||
|
cm.hostLocker.Lock()
|
||||||
|
defer cm.hostLocker.Unlock()
|
||||||
|
|
||||||
cm.host = rootURL
|
cm.host = rootURL
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ func NewBasicTLSDialer() *BasicTLSDialer {
|
|||||||
|
|
||||||
// DialTLS returns a connection to the given address using the given network.
|
// DialTLS returns a connection to the given address using the given network.
|
||||||
func (b *BasicTLSDialer) DialTLS(network, address string) (conn net.Conn, err error) {
|
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
|
var tlsConfig *tls.Config = nil
|
||||||
|
|
||||||
|
|||||||
@ -30,8 +30,8 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
proxyUseDuration = 24 * time.Hour
|
proxyUseDuration = 24 * time.Hour
|
||||||
proxySearchTimeout = 30 * time.Second
|
proxySearchTimeout = 20 * time.Second
|
||||||
proxyQueryTimeout = 10 * time.Second
|
proxyQueryTimeout = 20 * time.Second
|
||||||
proxyLookupWait = 5 * time.Second
|
proxyLookupWait = 5 * time.Second
|
||||||
proxyQuery = "dMFYGSLTQOJXXI33ONVQWS3BOMNUA.protonpro.xyz"
|
proxyQuery = "dMFYGSLTQOJXXI33ONVQWS3BOMNUA.protonpro.xyz"
|
||||||
)
|
)
|
||||||
@ -144,12 +144,12 @@ func (p *proxyProvider) canReach(url string) bool {
|
|||||||
url = "https://" + url
|
url = "https://" + url
|
||||||
}
|
}
|
||||||
|
|
||||||
pinningDialer := NewPinningTLSDialer(NewBasicTLSDialer())
|
dialer := NewPinningTLSDialer(NewBasicTLSDialer())
|
||||||
|
|
||||||
pinger := resty.New().
|
pinger := resty.New().
|
||||||
SetHostURL(url).
|
SetHostURL(url).
|
||||||
SetTimeout(p.lookupTimeout).
|
SetTimeout(p.lookupTimeout).
|
||||||
SetTransport(CreateTransportWithDialer(pinningDialer))
|
SetTransport(CreateTransportWithDialer(dialer))
|
||||||
|
|
||||||
if _, err := pinger.R().Get("/tests/ping"); err != nil {
|
if _, err := pinger.R().Get("/tests/ping"); err != nil {
|
||||||
logrus.WithField("proxy", url).WithError(err).Warn("Failed to ping proxy")
|
logrus.WithField("proxy", url).WithError(err).Warn("Failed to ping proxy")
|
||||||
|
|||||||
Reference in New Issue
Block a user