0
0
mirror of https://github.com/vx3r/wg-gen-web.git synced 2025-09-11 12:24:27 +00:00

default client allowed ips in server config

This commit is contained in:
Stephen Boyle
2020-04-14 12:47:56 -04:00
parent eecea63d18
commit 260f73336f
4 changed files with 44 additions and 1 deletions

View File

@ -16,6 +16,7 @@ type Server struct {
Endpoint string `json:"endpoint"`
PersistentKeepalive int `json:"persistentKeepalive"`
Dns []string `json:"dns"`
AllowedIPs []string `json:"allowedips"`
PreUp string `json:"preUp"`
PostUp string `json:"postUp"`
PreDown string `json:"preDown"`
@ -59,6 +60,12 @@ func (a Server) IsValid() []error {
errs = append(errs, fmt.Errorf("dns %s is invalid", dns))
}
}
// check if the allowedIPs are valid
for _, allowedIP := range a.AllowedIPs {
if !util.IsValidCidr(allowedIP) {
errs = append(errs, fmt.Errorf("allowedIP %s is invalid", allowedIP))
}
}
return errs
}