generated from kedaya_haitao/template
fix 修复proxies 替换时names没换的bug
This commit is contained in:
parent
0f07bb9f10
commit
a581c72a65
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user