fix: proxy-groups filter logic

This commit is contained in:
adlyq
2022-04-22 17:27:55 +08:00
parent b0dd74e74e
commit 8a85c63b08
17 changed files with 63 additions and 3 deletions

View File

@ -29,8 +29,9 @@ func getProvidersProxies(providers []provider.ProxyProvider, touch bool, filter
//filterReg = regexp.MustCompile(filter)
filterReg = regexp2.MustCompile(filter, 0)
for _, p := range proxies {
if p.Type() < 8 {
if p.IsProxyGroup() {
matchedProxies = append(matchedProxies, p)
continue
}
//if filterReg.MatchString(p.Name()) {

View File

@ -24,6 +24,10 @@ type Fallback struct {
failedTime *atomic.Int64
}
func (f *Fallback) IsProxyGroup() bool {
return true
}
func (f *Fallback) Now() string {
proxy := f.findAliveProxy(false)
return proxy.Name()

View File

@ -28,6 +28,10 @@ type LoadBalance struct {
strategyFn strategyFn
}
func (lb *LoadBalance) IsProxyGroup() bool {
return true
}
var errStrategy = errors.New("unsupported strategy")
func parseStrategy(config map[string]any) string {

View File

@ -19,6 +19,10 @@ type Relay struct {
filter string
}
func (r *Relay) IsProxyGroup() bool {
return true
}
// DialContext implements C.ProxyAdapter
func (r *Relay) DialContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (C.Conn, error) {
var proxies []C.Proxy

View File

@ -21,6 +21,10 @@ type Selector struct {
providers []provider.ProxyProvider
}
func (s *Selector) IsProxyGroup() bool {
return true
}
// DialContext implements C.ProxyAdapter
func (s *Selector) DialContext(ctx context.Context, metadata *C.Metadata, opts ...dialer.Option) (C.Conn, error) {
c, err := s.selectedProxy(true).DialContext(ctx, metadata, s.Base.DialOptions(opts...)...)

View File

@ -35,6 +35,10 @@ type URLTest struct {
failedTime *atomic.Int64
}
func (u *URLTest) IsProxyGroup() bool {
return true
}
func (u *URLTest) Now() string {
return u.fast(false).Name()
}