mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-21 20:12:33 +03:00
moved length test to util, tests fine
This commit is contained in:
parent
b0780d3bf5
commit
f3d76cf35d
2 changed files with 5 additions and 3 deletions
|
@ -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"})
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue