mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-07-28 20:10:50 +03:00
Merge 97e7ead5fd
into e73047b14f
This commit is contained in:
commit
2dbbb8a098
9 changed files with 268 additions and 6 deletions
18
util/util.go
18
util/util.go
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue