From a775ef00776150155bd715fa178dfa5711db737e Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sat, 23 Mar 2019 16:29:27 +0800 Subject: [PATCH] Fix: fallback & url-test lose efficacy --- adapters/outbound/base.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/adapters/outbound/base.go b/adapters/outbound/base.go index f234ced6..7941c2f7 100644 --- a/adapters/outbound/base.go +++ b/adapters/outbound/base.go @@ -56,16 +56,20 @@ func (p *Proxy) DelayHistory() []C.DelayHistory { return histories } +// LastDelay return last history record. if proxy is not alive, return the max value of int16. func (p *Proxy) LastDelay() (delay uint16) { + var max uint16 = 0xffff + if !p.alive { + return max + } + head := p.history.First() if head == nil { - delay-- - return + return max } history := head.(C.DelayHistory) if history.Delay == 0 { - delay-- - return + return max } return history.Delay } @@ -101,7 +105,7 @@ func (p *Proxy) URLTest(url string) (t uint16, err error) { } start := time.Now() - instance, err := p.ProxyAdapter.Dial(&addr) + instance, err := p.Dial(&addr) if err != nil { return }