fix(group): policy 'fixed' parsing (#149)

This commit is contained in:
mzz 2023-06-18 14:24:33 +08:00 committed by GitHub
parent 1546f30e4e
commit d3dcfe6bb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,12 +37,12 @@ func NewDialerSelectionPolicyFromGroupParam(param *config.Group) (policy *Dialer
if f.Not {
return nil, fmt.Errorf("policy param does not support not operator: !%v()", f.Name)
}
if len(f.Params) > 1 || f.Params[0].Key != "" {
if len(f.Params) != 1 || f.Params[0].Key != "" {
return nil, fmt.Errorf(`invalid "%v" param format`, f.Name)
}
strIndex := f.Params[0].Val
index, err := strconv.Atoi(strIndex)
if len(f.Params) > 1 || f.Params[0].Key != "" {
if err != nil {
return nil, fmt.Errorf(`invalid "%v" param format: %w`, f.Name, err)
}
return &DialerSelectionPolicy{