moved length test to util, tests fine
This commit is contained in:
		
							parent
							
								
									b0780d3bf5
								
							
						
					
					
						commit
						f3d76cf35d
					
				| 
						 | 
					@ -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"})
 | 
								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)
 | 
					            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"})
 | 
					            return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, "Extra Allowed IPs must be in CIDR format"})
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,8 +78,10 @@ func ValidateCIDR(cidr string) bool {
 | 
				
			||||||
// ValidateCIDRList to validate a list of network CIDR
 | 
					// ValidateCIDRList to validate a list of network CIDR
 | 
				
			||||||
func ValidateCIDRList(cidrs []string) bool {
 | 
					func ValidateCIDRList(cidrs []string) bool {
 | 
				
			||||||
	for _, cidr := range cidrs {
 | 
						for _, cidr := range cidrs {
 | 
				
			||||||
		if ValidateCIDR(cidr) == false {
 | 
						    if len(cidr) > 0 {
 | 
				
			||||||
			return false
 | 
					            if ValidateCIDR(cidr) == false {
 | 
				
			||||||
 | 
					                return false
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue