mirror of
https://github.com/swissmakers/wireguard-manager.git
synced 2026-04-11 13:47:05 +02:00
Add Server config page
Handle server ip addresses input and store TODO: Key pair form
This commit is contained in:
22
util/util.go
22
util/util.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user