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 }