Add Server config page

Handle server ip addresses input and store
TODO: Key pair form
This commit is contained in:
Khanh Ngo 2020-04-19 15:50:59 +07:00
parent 20fcdbafa5
commit febf075f8d
No known key found for this signature in database
GPG key ID: D5FAA6A16150E49E
9 changed files with 285 additions and 22 deletions

View file

@ -40,7 +40,7 @@ func BuildClientConfig(client model.Client) string {
return strConfig
}
// ValidateCIDR to validate an network CIDR
// ValidateCIDR to validate a network CIDR
func ValidateCIDR(cidr string) bool {
_, _, err := net.ParseCIDR(cidr)
if err != nil {
@ -49,8 +49,8 @@ func ValidateCIDR(cidr string) bool {
return true
}
// ValidateAllowedIPs to validate allowed ip addresses in CIDR format.
func ValidateAllowedIPs(cidrs []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
@ -58,3 +58,19 @@ func ValidateAllowedIPs(cidrs []string) bool {
}
return true
}
// ValidateAllowedIPs to validate allowed ip addresses in CIDR format
func ValidateAllowedIPs(cidrs []string) bool {
if ValidateCIDRList(cidrs) == false {
return false
}
return true
}
// ValidateServerAddresses to validate allowed ip addresses in CIDR format
func ValidateServerAddresses(cidrs []string) bool {
if ValidateCIDRList(cidrs) == false {
return false
}
return true
}