chore: Allow customization of GLOBAL

This commit is contained in:
xishang0128 2024-05-25 08:09:59 +08:00
parent 0b6ae6ffb8
commit 846bdfa812

View File

@ -716,8 +716,11 @@ func parseProxies(cfg *RawConfig) (proxies map[string]C.Proxy, providersMap map[
groupsConfig := cfg.ProxyGroup
providersConfig := cfg.ProxyProvider
var proxyList []string
var AllProxies []string
var (
proxyList []string
AllProxies []string
hasGlobal bool
)
proxiesList := list.New()
groupsList := list.New()
@ -750,6 +753,9 @@ func parseProxies(cfg *RawConfig) (proxies map[string]C.Proxy, providersMap map[
if !existName {
return nil, nil, fmt.Errorf("proxy group %d: missing name", idx)
}
if groupName == "GLOBAL" {
hasGlobal = true
}
proxyList = append(proxyList, groupName)
groupsList.PushBack(mapping)
}
@ -801,13 +807,15 @@ func parseProxies(cfg *RawConfig) (proxies map[string]C.Proxy, providersMap map[
pd, _ := provider.NewCompatibleProvider(provider.ReservedName, ps, hc)
providersMap[provider.ReservedName] = pd
global := outboundgroup.NewSelector(
&outboundgroup.GroupCommonOption{
Name: "GLOBAL",
},
[]providerTypes.ProxyProvider{pd},
)
proxies["GLOBAL"] = adapter.NewProxy(global)
if !hasGlobal {
global := outboundgroup.NewSelector(
&outboundgroup.GroupCommonOption{
Name: "GLOBAL",
},
[]providerTypes.ProxyProvider{pd},
)
proxies["GLOBAL"] = adapter.NewProxy(global)
}
ProxiesList = proxiesList
GroupsList = groupsList
if ParsingProxiesCallback != nil {