@@ -88,6 +88,29 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
88
88
}
89
89
groupOption .ExpectedStatus = status
90
90
91
+ if len (groupOption .Use ) != 0 {
92
+ PDs , err := getProviders (providersMap , groupOption .Use )
93
+ if err != nil {
94
+ return nil , fmt .Errorf ("%s: %w" , groupName , err )
95
+ }
96
+
97
+ // if test URL is empty, use the first health check URL of providers
98
+ if groupOption .URL == "" {
99
+ for _ , pd := range PDs {
100
+ if pd .HealthCheckURL () != "" {
101
+ groupOption .URL = pd .HealthCheckURL ()
102
+ break
103
+ }
104
+ }
105
+ if groupOption .URL == "" {
106
+ groupOption .URL = C .DefaultTestURL
107
+ }
108
+ } else {
109
+ addTestUrlToProviders (PDs , groupOption .URL , expectedStatus , groupOption .Filter , uint (groupOption .Interval ))
110
+ }
111
+ providers = append (providers , PDs ... )
112
+ }
113
+
91
114
if len (groupOption .Proxies ) != 0 {
92
115
ps , err := getProxies (proxyMap , groupOption .Proxies )
93
116
if err != nil {
@@ -98,49 +121,28 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
98
121
return nil , fmt .Errorf ("%s: %w" , groupName , errDuplicateProvider )
99
122
}
100
123
101
- if groupOption .Interval == 0 {
102
- groupOption .Interval = 300
103
- }
104
-
105
124
if groupOption .URL == "" {
106
125
groupOption .URL = C .DefaultTestURL
107
126
}
108
127
128
+ // select don't need auto health check
129
+ if groupOption .Type != "select" && groupOption .Type != "relay" {
130
+ if groupOption .Interval == 0 {
131
+ groupOption .Interval = 300
132
+ }
133
+ }
134
+
109
135
hc := provider .NewHealthCheck (ps , groupOption .URL , uint (groupOption .TestTimeout ), uint (groupOption .Interval ), groupOption .Lazy , expectedStatus )
110
136
111
137
pd , err := provider .NewCompatibleProvider (groupName , ps , hc )
112
138
if err != nil {
113
139
return nil , fmt .Errorf ("%s: %w" , groupName , err )
114
140
}
115
141
116
- providers = append (providers , pd )
142
+ providers = append ([]types. ProxyProvider { pd }, providers ... )
117
143
providersMap [groupName ] = pd
118
144
}
119
145
120
- if len (groupOption .Use ) != 0 {
121
- list , err := getProviders (providersMap , groupOption .Use )
122
- if err != nil {
123
- return nil , fmt .Errorf ("%s: %w" , groupName , err )
124
- }
125
-
126
- if groupOption .URL == "" {
127
- for _ , p := range list {
128
- if p .HealthCheckURL () != "" {
129
- groupOption .URL = p .HealthCheckURL ()
130
- }
131
- break
132
- }
133
-
134
- if groupOption .URL == "" {
135
- groupOption .URL = C .DefaultTestURL
136
- }
137
- }
138
-
139
- // different proxy groups use different test URL
140
- addTestUrlToProviders (list , groupOption .URL , expectedStatus , groupOption .Filter , uint (groupOption .Interval ))
141
- providers = append (providers , list ... )
142
- }
143
-
144
146
var group C.ProxyAdapter
145
147
switch groupOption .Type {
146
148
case "url-test" :
0 commit comments