mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-07-01 16:35:37 +03:00
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:
parent
fdb36e4711
commit
5fff577c60
9 changed files with 293 additions and 7 deletions
18
util/util.go
18
util/util.go
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue