From 972d3f1d395ce057871b91a21e8f3442a639688e Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Mon, 31 Oct 2022 16:45:14 +0800 Subject: [PATCH] fix: UrlTest's torch not work close #232 --- adapter/outboundgroup/groupbase.go | 6 ++++++ adapter/outboundgroup/urltest.go | 3 +++ constant/adapters.go | 1 + 3 files changed, 10 insertions(+) diff --git a/adapter/outboundgroup/groupbase.go b/adapter/outboundgroup/groupbase.go index 36ee6c13..0c9ea02c 100644 --- a/adapter/outboundgroup/groupbase.go +++ b/adapter/outboundgroup/groupbase.go @@ -56,6 +56,12 @@ func NewGroupBase(opt GroupBaseOption) *GroupBase { return gb } +func (gb *GroupBase) Touch() { + for _, pd := range gb.providers { + pd.Touch() + } +} + func (gb *GroupBase) GetProxies(touch bool) []C.Proxy { if len(gb.filterRegs) == 0 { var proxies []C.Proxy diff --git a/adapter/outboundgroup/urltest.go b/adapter/outboundgroup/urltest.go index 2d0f560f..a0fbe6d1 100644 --- a/adapter/outboundgroup/urltest.go +++ b/adapter/outboundgroup/urltest.go @@ -61,6 +61,9 @@ func (u *URLTest) Unwrap(metadata *C.Metadata, touch bool) C.Proxy { } func (u *URLTest) fast(touch bool) C.Proxy { + if touch { + u.Touch() + } elm, _, _ := u.fastSingle.Do(func() (C.Proxy, error) { proxies := u.GetProxies(touch) fast := proxies[0] diff --git a/constant/adapters.go b/constant/adapters.go index 6333e8e0..7fc31667 100644 --- a/constant/adapters.go +++ b/constant/adapters.go @@ -112,6 +112,7 @@ type ProxyAdapter interface { type Group interface { URLTest(ctx context.Context, url string) (mp map[string]uint16, err error) GetProxies(touch bool) []Proxy + Touch() } type DelayHistory struct {