Skip to content

Commit

Permalink
revert: "modify default url"
Browse files Browse the repository at this point in the history
This reverts commit 3d643cb.
  • Loading branch information
Larvan2 committed Feb 24, 2024
1 parent f8295a0 commit d2a5376
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
39 changes: 16 additions & 23 deletions adapter/outboundgroup/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,15 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
groupOption.IncludeAllProviders = true
groupOption.IncludeAllProxies = true
}
var GroupUse []string
var GroupProxies []string

if groupOption.IncludeAllProviders {
GroupUse = append(GroupUse, AllProviders...)
} else {
GroupUse = groupOption.Use
groupOption.Use = append(groupOption.Use, AllProviders...)
}
if groupOption.IncludeAllProxies {
GroupProxies = append(groupOption.Proxies, AllProxies...)
} else {
GroupProxies = groupOption.Proxies
groupOption.Proxies = append(groupOption.Proxies, AllProxies...)
}

if len(GroupProxies) == 0 && len(GroupUse) == 0 {
if len(groupOption.Proxies) == 0 && len(groupOption.Use) == 0 {
return nil, fmt.Errorf("%s: %w", groupName, errMissProxy)
}

Expand All @@ -91,17 +86,9 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
status = "*"
}
groupOption.ExpectedStatus = status
testUrl := groupOption.URL

if groupOption.Type != "select" && groupOption.Type != "relay" {
if groupOption.URL == "" {
groupOption.URL = C.DefaultTestURL
testUrl = groupOption.URL
}
}

if len(GroupProxies) != 0 {
ps, err := getProxies(proxyMap, GroupProxies)
if len(groupOption.Proxies) != 0 {
ps, err := getProxies(proxyMap, groupOption.Proxies)
if err != nil {
return nil, fmt.Errorf("%s: %w", groupName, err)
}
Expand All @@ -115,9 +102,12 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
if groupOption.Interval == 0 {
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)
if err != nil {
Expand All @@ -128,14 +118,17 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
providersMap[groupName] = pd
}

if len(GroupUse) != 0 {
list, err := getProviders(providersMap, GroupUse)
if len(groupOption.Use) != 0 {
if groupOption.URL == "" {
groupOption.URL = C.DefaultTestURL
}
list, err := getProviders(providersMap, groupOption.Use)
if err != nil {
return nil, fmt.Errorf("%s: %w", groupName, err)
}

// 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...)
} else {
Expand Down
4 changes: 2 additions & 2 deletions adapter/provider/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
if url == "" {
// expectedStatus = nil
url = C.DefaultTestURL
expectedStatus = nil
interval = 0
}
if timeout == 0 {
timeout = 5000
Expand Down

0 comments on commit d2a5376

Please sign in to comment.