File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 "encoding/hex"
66 "errors"
77 "fmt"
8- "net"
98 "reflect"
109 "slices"
1110 "strings"
@@ -286,11 +285,11 @@ func (c *Controller) validateSgRule(sg *kubeovnv1.SecurityGroup) error {
286285 switch rule .RemoteType {
287286 case kubeovnv1 .SgRemoteTypeAddress :
288287 if strings .Contains (rule .RemoteAddress , "/" ) {
289- if _ , _ , err := net . ParseCIDR (rule .RemoteAddress ); err != nil {
288+ if err := util . CheckCidrs (rule .RemoteAddress ); err != nil {
290289 return fmt .Errorf ("invalid CIDR '%s'" , rule .RemoteAddress )
291290 }
292291 } else {
293- if net . ParseIP (rule .RemoteAddress ) == nil {
292+ if ! util . IsValidIP (rule .RemoteAddress ) {
294293 return fmt .Errorf ("invalid ip address '%s'" , rule .RemoteAddress )
295294 }
296295 }
@@ -305,11 +304,11 @@ func (c *Controller) validateSgRule(sg *kubeovnv1.SecurityGroup) error {
305304
306305 if rule .LocalAddress != "" {
307306 if strings .Contains (rule .LocalAddress , "/" ) {
308- if _ , _ , err := net . ParseCIDR (rule .LocalAddress ); err != nil {
307+ if err := util . CheckCidrs (rule .LocalAddress ); err != nil {
309308 return fmt .Errorf ("invalid CIDR '%s'" , rule .LocalAddress )
310309 }
311310 } else {
312- if net . ParseIP (rule .LocalAddress ) == nil {
311+ if ! util . IsValidIP (rule .LocalAddress ) {
313312 return fmt .Errorf ("invalid ip address '%s'" , rule .LocalAddress )
314313 }
315314 }
You can’t perform that action at this time.
0 commit comments