moved length test to util, tests fine

This commit is contained in:
Britt Dodd 2022-01-10 11:18:04 -05:00
parent b0780d3bf5
commit f3d76cf35d
2 changed files with 5 additions and 3 deletions

View file

@ -280,7 +280,7 @@ func UpdateClient(db store.IStore) echo.HandlerFunc {
return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, "Allowed IPs must be in CIDR format"})
}
if len(_client.ExtraAllowedIPs) > 0 && util.ValidateAllowedIPs(_client.ExtraAllowedIPs) == false {
if util.ValidateAllowedIPs(_client.ExtraAllowedIPs) == false {
log.Warnf("Invalid Allowed IPs input from user: %v", _client.ExtraAllowedIPs)
return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, "Extra Allowed IPs must be in CIDR format"})
}

View file

@ -78,8 +78,10 @@ func ValidateCIDR(cidr string) bool {
// ValidateCIDRList to validate a list of network CIDR
func ValidateCIDRList(cidrs []string) bool {
for _, cidr := range cidrs {
if ValidateCIDR(cidr) == false {
return false
if len(cidr) > 0 {
if ValidateCIDR(cidr) == false {
return false
}
}
}
return true