Fix: fallback & url-test lose efficacy
This commit is contained in:
parent
7a9d986ff3
commit
f99da37168
1 changed files with 9 additions and 5 deletions
|
@ -56,16 +56,20 @@ func (p *Proxy) DelayHistory() []C.DelayHistory {
|
||||||
return histories
|
return histories
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LastDelay return last history record. if proxy is not alive, return the max value of int16.
|
||||||
func (p *Proxy) LastDelay() (delay uint16) {
|
func (p *Proxy) LastDelay() (delay uint16) {
|
||||||
|
var max uint16 = 0xffff
|
||||||
|
if !p.alive {
|
||||||
|
return max
|
||||||
|
}
|
||||||
|
|
||||||
head := p.history.First()
|
head := p.history.First()
|
||||||
if head == nil {
|
if head == nil {
|
||||||
delay--
|
return max
|
||||||
return
|
|
||||||
}
|
}
|
||||||
history := head.(C.DelayHistory)
|
history := head.(C.DelayHistory)
|
||||||
if history.Delay == 0 {
|
if history.Delay == 0 {
|
||||||
delay--
|
return max
|
||||||
return
|
|
||||||
}
|
}
|
||||||
return history.Delay
|
return history.Delay
|
||||||
}
|
}
|
||||||
|
@ -101,7 +105,7 @@ func (p *Proxy) URLTest(url string) (t uint16, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
instance, err := p.ProxyAdapter.Dial(&addr)
|
instance, err := p.Dial(&addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue