fix: npe when parse rule

This commit is contained in:
Skyxim
2022-04-16 00:21:08 +08:00
parent 36a719e2f8
commit 45fe6e996b
6 changed files with 86 additions and 42 deletions

View File

@ -1,8 +1,6 @@
package logic
import (
"fmt"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/rule/common"
)
@ -21,16 +19,12 @@ func (A *AND) ShouldFindProcess() bool {
func NewAND(payload string, adapter string) (*AND, error) {
and := &AND{Base: &common.Base{}, payload: payload, adapter: adapter}
rules, err := parseRuleByPayload(payload, true)
rules, err := parseRuleByPayload(payload)
if err != nil {
return nil, err
}
and.rules = rules
if len(and.rules) == 0 {
return nil, fmt.Errorf("And rule is error, may be format error or not contain least one rule")
}
for _, rule := range rules {
if rule.ShouldResolveIP() {
and.needIP = true