mirror of
https://github.com/alibaba/higress.git
synced 2026-03-04 00:20:50 +08:00
fix: Allow duplicated items in the IP list of ip-restriction config (#2755)
Co-authored-by: 澄潭 <zty98751@alibaba-inc.com>
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/asergeyev/nradix"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/zmap/go-iptree/iptree"
|
||||
|
||||
"github.com/higress-group/wasm-go/pkg/log"
|
||||
)
|
||||
|
||||
// parseIPNets 解析Ip段配置
|
||||
@@ -17,7 +21,12 @@ func parseIPNets(array []gjson.Result) (*iptree.IPTree, error) {
|
||||
for _, result := range array {
|
||||
err := tree.AddByString(result.String(), 0)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid IP[%s]", result.String())
|
||||
if errors.Is(err, nradix.ErrNodeBusy) {
|
||||
// ErrNodeBusy means the IP already exists in the tree
|
||||
log.Warnf("ignore duplicate IP [%s]", result.String())
|
||||
} else {
|
||||
return nil, fmt.Errorf("add IP [%s] into tree failed: %v", result.String(), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return tree, nil
|
||||
|
||||
Reference in New Issue
Block a user