Added client default settings page

Added client default settings page, where you can set Allowed IPs, Extra Allowed IPs, use server dns, enable after creation.
This commit is contained in:
Arminas 2023-02-10 07:22:24 +02:00 committed by GitHub
parent fdb36e4711
commit 5fff577c60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 293 additions and 7 deletions

View file

@ -93,6 +93,24 @@ func ClientDefaultsFromEnv() model.ClientDefaults {
return clientDefaults
}
// ClientDefaultsFromDatabase to read the default values for creating a new client from the database
func ClientDefaultsFromDatabase() model.ClientDefaults {
// initialize database directory
dir := "./db"
db, err := scribble.New(dir, nil)
if err != nil {
panic(err)
}
// read client default settings
clientDefaults := model.ClientDefaults{}
if err := db.Read("server", "client_default_settings", &clientDefaults); err != nil {
panic(err)
}
return clientDefaults
}
// ValidateCIDR to validate a network CIDR
func ValidateCIDR(cidr string) bool {
_, _, err := net.ParseCIDR(cidr)