From 595a575cdebaf3ea8806e74b35f895906286b23e Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Mon, 9 Sep 2024 09:15:37 +0800 Subject: [PATCH] chore: add Count for ProxyProvider --- adapter/provider/provider.go | 8 ++++++++ constant/provider/interface.go | 1 + 2 files changed, 9 insertions(+) diff --git a/adapter/provider/provider.go b/adapter/provider/provider.go index a99c1d96..923cddba 100644 --- a/adapter/provider/provider.go +++ b/adapter/provider/provider.go @@ -98,6 +98,10 @@ func (pp *proxySetProvider) Proxies() []C.Proxy { return pp.proxies } +func (pp *proxySetProvider) Count() int { + return len(pp.proxies) +} + func (pp *proxySetProvider) Touch() { pp.healthCheck.touch() } @@ -267,6 +271,10 @@ func (cp *compatibleProvider) Proxies() []C.Proxy { return cp.proxies } +func (cp *compatibleProvider) Count() int { + return len(cp.proxies) +} + func (cp *compatibleProvider) Touch() { cp.healthCheck.touch() } diff --git a/constant/provider/interface.go b/constant/provider/interface.go index 911f774a..880bdadf 100644 --- a/constant/provider/interface.go +++ b/constant/provider/interface.go @@ -71,6 +71,7 @@ type Provider interface { type ProxyProvider interface { Provider Proxies() []constant.Proxy + Count() int // Touch is used to inform the provider that the proxy is actually being used while getting the list of proxies. // Commonly used in DialContext and DialPacketConn Touch()