This commit is contained in:
Arminas 2023-12-26 17:28:22 +03:00 committed by GitHub
commit 2dbbb8a098
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 268 additions and 6 deletions

View file

@ -95,6 +95,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)