From 067027553373a3f9d13c8a73e64ed455ded3140c Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Wed, 17 Jul 2019 22:24:26 +0800 Subject: [PATCH] Fix(url-test): incorrect result --- adapters/outbound/urltest.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/adapters/outbound/urltest.go b/adapters/outbound/urltest.go index cfe6b5ba..9c6bd7d5 100644 --- a/adapters/outbound/urltest.go +++ b/adapters/outbound/urltest.go @@ -106,12 +106,13 @@ func (u *URLTest) speedTest() { defer cancel() picker, ctx := picker.WithContext(ctx) for _, p := range u.proxies { + proxy := p picker.Go(func() (interface{}, error) { - _, err := p.URLTest(ctx, u.rawURL) - if err != nil { - return nil, err + t, err := proxy.URLTest(ctx, u.rawURL) + if err != nil || t == 0 { + return nil, errors.New("speed test error") } - return p, nil + return proxy, nil }) }