Skip to content

Commit

Permalink
Fix: fallback & url-test lose efficacy
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Mar 23, 2019
1 parent 7a9d986 commit f99da37
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions adapters/outbound/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit f99da37

Please sign in to comment.