mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-05-24 00:24:06 +03:00
Add Server config page
Handle server ip addresses input and store TODO: Key pair form
This commit is contained in:
parent
20fcdbafa5
commit
febf075f8d
9 changed files with 285 additions and 22 deletions
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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue