diff --git a/plugins/wasm-go/extensions/ip-restriction/utils.go b/plugins/wasm-go/extensions/ip-restriction/utils.go index 7706faa3d..abc464ba5 100644 --- a/plugins/wasm-go/extensions/ip-restriction/utils.go +++ b/plugins/wasm-go/extensions/ip-restriction/utils.go @@ -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