@@ -331,15 +331,22 @@ func (cp *CompatibleProvider) Close() error {
331
331
}
332
332
333
333
func NewProxiesParser (filter string , excludeFilter string , excludeType string , dialerProxy string , override OverrideSchema ) (resource.Parser [[]C.Proxy ], error ) {
334
- excludeFilterReg , err := regexp2 .Compile (excludeFilter , regexp2 .None )
335
- if err != nil {
336
- return nil , fmt .Errorf ("invalid excludeFilter regex: %w" , err )
337
- }
338
334
var excludeTypeArray []string
339
335
if excludeType != "" {
340
336
excludeTypeArray = strings .Split (excludeType , "|" )
341
337
}
342
338
339
+ var excludeFilterRegs []* regexp2.Regexp
340
+ if excludeFilter != "" {
341
+ for _ , excludeFilter := range strings .Split (excludeFilter , "`" ) {
342
+ excludeFilterReg , err := regexp2 .Compile (excludeFilter , regexp2 .None )
343
+ if err != nil {
344
+ return nil , fmt .Errorf ("invalid excludeFilter regex: %w" , err )
345
+ }
346
+ excludeFilterRegs = append (excludeFilterRegs , excludeFilterReg )
347
+ }
348
+ }
349
+
343
350
var filterRegs []* regexp2.Regexp
344
351
for _ , filter := range strings .Split (filter , "`" ) {
345
352
filterReg , err := regexp2 .Compile (filter , regexp2 .None )
@@ -367,8 +374,9 @@ func NewProxiesParser(filter string, excludeFilter string, excludeType string, d
367
374
proxies := []C.Proxy {}
368
375
proxiesSet := map [string ]struct {}{}
369
376
for _ , filterReg := range filterRegs {
377
+ LOOP1:
370
378
for idx , mapping := range schema .Proxies {
371
- if nil != excludeTypeArray && len (excludeTypeArray ) > 0 {
379
+ if len (excludeTypeArray ) > 0 {
372
380
mType , ok := mapping ["type" ]
373
381
if ! ok {
374
382
continue
@@ -377,18 +385,11 @@ func NewProxiesParser(filter string, excludeFilter string, excludeType string, d
377
385
if ! ok {
378
386
continue
379
387
}
380
- flag := false
381
- for i := range excludeTypeArray {
382
- if strings .EqualFold (pType , excludeTypeArray [i ]) {
383
- flag = true
384
- break
388
+ for _ , excludeType := range excludeTypeArray {
389
+ if strings .EqualFold (pType , excludeType ) {
390
+ continue LOOP1
385
391
}
386
-
387
- }
388
- if flag {
389
- continue
390
392
}
391
-
392
393
}
393
394
mName , ok := mapping ["name" ]
394
395
if ! ok {
@@ -398,9 +399,11 @@ func NewProxiesParser(filter string, excludeFilter string, excludeType string, d
398
399
if ! ok {
399
400
continue
400
401
}
401
- if len (excludeFilter ) > 0 {
402
- if mat , _ := excludeFilterReg .MatchString (name ); mat {
403
- continue
402
+ if len (excludeFilterRegs ) > 0 {
403
+ for _ , excludeFilterReg := range excludeFilterRegs {
404
+ if mat , _ := excludeFilterReg .MatchString (name ); mat {
405
+ continue LOOP1
406
+ }
404
407
}
405
408
}
406
409
if len (filter ) > 0 {
0 commit comments