mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-07-26 20:00:27 +03:00
Added branding settings page
Added branding settings page, where you can change favicon, brand name and brand logo from UI.
This commit is contained in:
parent
46ac9ef2c1
commit
12d0dc6288
8 changed files with 384 additions and 15 deletions
|
@ -43,6 +43,9 @@ func (o *JsonDB) Init() error {
|
|||
var serverKeyPairPath string = path.Join(serverPath, "keypair.json")
|
||||
var globalSettingPath string = path.Join(serverPath, "global_settings.json")
|
||||
var userPath string = path.Join(serverPath, "users.json")
|
||||
var brandingPath string = path.Join(o.dbPath, "branding")
|
||||
var brandNamePath string = path.Join(brandingPath, "brand_name.json")
|
||||
|
||||
// create directories if they do not exist
|
||||
if _, err := os.Stat(clientPath); os.IsNotExist(err) {
|
||||
os.MkdirAll(clientPath, os.ModePerm)
|
||||
|
@ -53,6 +56,9 @@ func (o *JsonDB) Init() error {
|
|||
if _, err := os.Stat(wakeOnLanHostsPath); os.IsNotExist(err) {
|
||||
os.MkdirAll(wakeOnLanHostsPath, os.ModePerm)
|
||||
}
|
||||
if _, err := os.Stat(brandingPath); os.IsNotExist(err) {
|
||||
os.MkdirAll(brandingPath, os.ModePerm)
|
||||
}
|
||||
|
||||
// server's interface
|
||||
if _, err := os.Stat(serverInterfacePath); os.IsNotExist(err) {
|
||||
|
@ -117,6 +123,14 @@ func (o *JsonDB) Init() error {
|
|||
}
|
||||
o.conn.Write("server", "users", user)
|
||||
}
|
||||
// brand name
|
||||
if _, err := os.Stat(brandNamePath); os.IsNotExist(err) {
|
||||
type brandName struct {
|
||||
BrandName string `json:"brand_name"`
|
||||
}
|
||||
name := brandName{BrandName: "WIREGUARD UI"}
|
||||
o.conn.Write("branding", "brand_name", name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -213,7 +227,7 @@ func (o *JsonDB) GetClientByID(clientID string, qrCodeSettings model.QRCodeSetti
|
|||
server, _ := o.GetServer()
|
||||
globalSettings, _ := o.GetGlobalSettings()
|
||||
client := client
|
||||
if !qrCodeSettings.IncludeDNS{
|
||||
if !qrCodeSettings.IncludeDNS {
|
||||
globalSettings.DNSServers = []string{}
|
||||
}
|
||||
if !qrCodeSettings.IncludeMTU {
|
||||
|
@ -255,3 +269,30 @@ func (o *JsonDB) SaveServerKeyPair(serverKeyPair model.ServerKeypair) error {
|
|||
func (o *JsonDB) SaveGlobalSettings(globalSettings model.GlobalSetting) error {
|
||||
return o.conn.Write("server", "global_settings", globalSettings)
|
||||
}
|
||||
|
||||
// GetBrandName func to get brand name from the database
|
||||
func (o *JsonDB) GetBrandName() string {
|
||||
type brandName struct {
|
||||
BrandName string `json:"brand_name"`
|
||||
}
|
||||
name := brandName{}
|
||||
o.conn.Read("branding", "brand_name", &name)
|
||||
|
||||
if err := o.conn.Read("branding", "brand_name", &name); err != nil {
|
||||
return "WIREGUARD UI"
|
||||
}
|
||||
|
||||
return name.BrandName
|
||||
}
|
||||
|
||||
func (o *JsonDB) SetBrandName(brandName string) error {
|
||||
type brandNameStruct struct {
|
||||
BrandName string `json:"brand_name"`
|
||||
}
|
||||
name := brandNameStruct{BrandName: brandName}
|
||||
return o.conn.Write("branding", "brand_name", name)
|
||||
}
|
||||
|
||||
func (o *JsonDB) GetPath() string {
|
||||
return o.dbPath
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue