mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-05-13 21:48:02 +08:00
parent
f8295a02fd
commit
d2a5376cb8
@ -64,20 +64,15 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
|
|||||||
groupOption.IncludeAllProviders = true
|
groupOption.IncludeAllProviders = true
|
||||||
groupOption.IncludeAllProxies = true
|
groupOption.IncludeAllProxies = true
|
||||||
}
|
}
|
||||||
var GroupUse []string
|
|
||||||
var GroupProxies []string
|
|
||||||
if groupOption.IncludeAllProviders {
|
if groupOption.IncludeAllProviders {
|
||||||
GroupUse = append(GroupUse, AllProviders...)
|
groupOption.Use = append(groupOption.Use, AllProviders...)
|
||||||
} else {
|
|
||||||
GroupUse = groupOption.Use
|
|
||||||
}
|
}
|
||||||
if groupOption.IncludeAllProxies {
|
if groupOption.IncludeAllProxies {
|
||||||
GroupProxies = append(groupOption.Proxies, AllProxies...)
|
groupOption.Proxies = append(groupOption.Proxies, AllProxies...)
|
||||||
} else {
|
|
||||||
GroupProxies = groupOption.Proxies
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(GroupProxies) == 0 && len(GroupUse) == 0 {
|
if len(groupOption.Proxies) == 0 && len(groupOption.Use) == 0 {
|
||||||
return nil, fmt.Errorf("%s: %w", groupName, errMissProxy)
|
return nil, fmt.Errorf("%s: %w", groupName, errMissProxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,17 +86,9 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
|
|||||||
status = "*"
|
status = "*"
|
||||||
}
|
}
|
||||||
groupOption.ExpectedStatus = status
|
groupOption.ExpectedStatus = status
|
||||||
testUrl := groupOption.URL
|
|
||||||
|
|
||||||
if groupOption.Type != "select" && groupOption.Type != "relay" {
|
if len(groupOption.Proxies) != 0 {
|
||||||
if groupOption.URL == "" {
|
ps, err := getProxies(proxyMap, groupOption.Proxies)
|
||||||
groupOption.URL = C.DefaultTestURL
|
|
||||||
testUrl = groupOption.URL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(GroupProxies) != 0 {
|
|
||||||
ps, err := getProxies(proxyMap, GroupProxies)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%s: %w", groupName, err)
|
return nil, fmt.Errorf("%s: %w", groupName, err)
|
||||||
}
|
}
|
||||||
@ -115,9 +102,12 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
|
|||||||
if groupOption.Interval == 0 {
|
if groupOption.Interval == 0 {
|
||||||
groupOption.Interval = 300
|
groupOption.Interval = 300
|
||||||
}
|
}
|
||||||
|
if groupOption.URL == "" {
|
||||||
|
groupOption.URL = C.DefaultTestURL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := provider.NewHealthCheck(ps, testUrl, uint(groupOption.TestTimeout), uint(groupOption.Interval), groupOption.Lazy, expectedStatus)
|
hc := provider.NewHealthCheck(ps, groupOption.URL, uint(groupOption.TestTimeout), uint(groupOption.Interval), groupOption.Lazy, expectedStatus)
|
||||||
|
|
||||||
pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
|
pd, err := provider.NewCompatibleProvider(groupName, ps, hc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -128,14 +118,17 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
|
|||||||
providersMap[groupName] = pd
|
providersMap[groupName] = pd
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(GroupUse) != 0 {
|
if len(groupOption.Use) != 0 {
|
||||||
list, err := getProviders(providersMap, GroupUse)
|
if groupOption.URL == "" {
|
||||||
|
groupOption.URL = C.DefaultTestURL
|
||||||
|
}
|
||||||
|
list, err := getProviders(providersMap, groupOption.Use)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%s: %w", groupName, err)
|
return nil, fmt.Errorf("%s: %w", groupName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// different proxy groups use different test URL
|
// different proxy groups use different test URL
|
||||||
addTestUrlToProviders(list, testUrl, expectedStatus, groupOption.Filter, uint(groupOption.Interval))
|
addTestUrlToProviders(list, groupOption.URL, expectedStatus, groupOption.Filter, uint(groupOption.Interval))
|
||||||
|
|
||||||
providers = append(providers, list...)
|
providers = append(providers, list...)
|
||||||
} else {
|
} else {
|
||||||
|
@ -211,8 +211,8 @@ func (hc *HealthCheck) close() {
|
|||||||
|
|
||||||
func NewHealthCheck(proxies []C.Proxy, url string, timeout uint, interval uint, lazy bool, expectedStatus utils.IntRanges[uint16]) *HealthCheck {
|
func NewHealthCheck(proxies []C.Proxy, url string, timeout uint, interval uint, lazy bool, expectedStatus utils.IntRanges[uint16]) *HealthCheck {
|
||||||
if url == "" {
|
if url == "" {
|
||||||
// expectedStatus = nil
|
expectedStatus = nil
|
||||||
url = C.DefaultTestURL
|
interval = 0
|
||||||
}
|
}
|
||||||
if timeout == 0 {
|
if timeout == 0 {
|
||||||
timeout = 5000
|
timeout = 5000
|
||||||
|
Loading…
Reference in New Issue
Block a user