From a581c72a6519e22ac2a41827ae2291c9053dd65c Mon Sep 17 00:00:00 2001 From: timerzz Date: Wed, 11 Dec 2024 11:24:59 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8Dproxies=20=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E6=97=B6names=E6=B2=A1=E6=8D=A2=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/proxy/structs/list.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/proxy/structs/list.go b/pkg/proxy/structs/list.go index 67d79b2..892d63b 100644 --- a/pkg/proxy/structs/list.go +++ b/pkg/proxy/structs/list.go @@ -11,7 +11,7 @@ var ProxiesList = NewProxies(make([]Proxy, 0)) type Proxies struct { proxies []Proxy - names sync.Map + names *sync.Map m sync.RWMutex } @@ -40,6 +40,7 @@ func (p *Proxy) Mapping() map[string]any { func NewProxies(proxies []Proxy) *Proxies { return &Proxies{ proxies: proxies, + names: &sync.Map{}, } } @@ -108,7 +109,13 @@ func (p *Proxies) Mapping() []map[string]any { // 替换 func (p *Proxies) Replace(proxies []Proxy) { + names := &sync.Map{} + for _, proxy := range proxies { + name := proxy.ClashProxy().Name() + names.Store(name, struct{}{}) + } p.m.Lock() defer p.m.Unlock() + p.names = names p.proxies = proxies }