proxy-groups support exclude node by node type
This commit is contained in:
@ -20,6 +20,7 @@ type GroupBase struct {
|
||||
*outbound.Base
|
||||
filterRegs []*regexp2.Regexp
|
||||
excludeFilterReg *regexp2.Regexp
|
||||
excludeTypeArray []string
|
||||
providers []provider.ProxyProvider
|
||||
failedTestMux sync.Mutex
|
||||
failedTimes int
|
||||
@ -33,6 +34,7 @@ type GroupBaseOption struct {
|
||||
outbound.BaseOption
|
||||
filter string
|
||||
excludeFilter string
|
||||
excludeType string
|
||||
providers []provider.ProxyProvider
|
||||
}
|
||||
|
||||
@ -41,6 +43,10 @@ func NewGroupBase(opt GroupBaseOption) *GroupBase {
|
||||
if opt.excludeFilter != "" {
|
||||
excludeFilterReg = regexp2.MustCompile(opt.excludeFilter, 0)
|
||||
}
|
||||
var excludeTypeArray []string
|
||||
if opt.excludeType!="" {
|
||||
excludeTypeArray=strings.Split(opt.excludeType,"|")
|
||||
}
|
||||
|
||||
var filterRegs []*regexp2.Regexp
|
||||
if opt.filter != "" {
|
||||
@ -54,6 +60,7 @@ func NewGroupBase(opt GroupBaseOption) *GroupBase {
|
||||
Base: outbound.NewBase(opt.BaseOption),
|
||||
filterRegs: filterRegs,
|
||||
excludeFilterReg: excludeFilterReg,
|
||||
excludeTypeArray: excludeTypeArray,
|
||||
providers: opt.providers,
|
||||
failedTesting: atomic.NewBool(false),
|
||||
}
|
||||
@ -148,6 +155,24 @@ func (gb *GroupBase) GetProxies(touch bool) []C.Proxy {
|
||||
}
|
||||
proxies = newProxies
|
||||
}
|
||||
if gb.excludeTypeArray !=nil{
|
||||
var newProxies []C.Proxy
|
||||
for _, p := range proxies {
|
||||
mType := p.Type().String()
|
||||
flag:=false
|
||||
for i := range gb.excludeTypeArray {
|
||||
if(strings.EqualFold(mType,gb.excludeTypeArray[i])){
|
||||
flag=true
|
||||
}
|
||||
|
||||
}
|
||||
if(flag){
|
||||
continue
|
||||
}
|
||||
newProxies = append(newProxies, p)
|
||||
}
|
||||
proxies = newProxies
|
||||
}
|
||||
|
||||
if gb.excludeFilterReg != nil {
|
||||
var newProxies []C.Proxy
|
||||
|
Reference in New Issue
Block a user