mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-15 07:11:15 +00:00
V2 alpha - initial version (#172)
Initial alpha codebase for version 2 of WireGuard Portal. This version is considered unstable and incomplete (for example, no public REST API)! Use with care! Fixes/Implements the following issues: - OAuth support #154, #1 - New Web UI with internationalisation support #98, #107, #89, #62 - Postgres Support #49 - Improved Email handling #47, #119 - DNS Search Domain support #46 - Bugfixes #94, #48 --------- Co-authored-by: Fabian Wechselberger <wechselbergerf@hotmail.com>
This commit is contained in:
113
internal/domain/options.go
Normal file
113
internal/domain/options.go
Normal file
@@ -0,0 +1,113 @@
|
||||
package domain
|
||||
|
||||
type StringConfigOption struct {
|
||||
Value string `gorm:"column:v"`
|
||||
Overridable bool `gorm:"column:o"`
|
||||
}
|
||||
|
||||
func (o StringConfigOption) GetValue() string {
|
||||
return o.Value
|
||||
}
|
||||
|
||||
func (o *StringConfigOption) SetValue(value string) {
|
||||
o.Value = value
|
||||
}
|
||||
|
||||
func (o *StringConfigOption) TrySetValue(value string) bool {
|
||||
if o.Overridable {
|
||||
o.Value = value
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func NewStringConfigOption(value string, overridable bool) StringConfigOption {
|
||||
return StringConfigOption{
|
||||
Value: value,
|
||||
Overridable: overridable,
|
||||
}
|
||||
}
|
||||
|
||||
type IntConfigOption struct {
|
||||
Value int `gorm:"column:v"`
|
||||
Overridable bool `gorm:"column:o"`
|
||||
}
|
||||
|
||||
func (o IntConfigOption) GetValue() int {
|
||||
return o.Value
|
||||
}
|
||||
|
||||
func (o *IntConfigOption) SetValue(value int) {
|
||||
o.Value = value
|
||||
}
|
||||
|
||||
func (o *IntConfigOption) TrySetValue(value int) bool {
|
||||
if o.Overridable {
|
||||
o.Value = value
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func NewIntConfigOption(value int, overridable bool) IntConfigOption {
|
||||
return IntConfigOption{
|
||||
Value: value,
|
||||
Overridable: overridable,
|
||||
}
|
||||
}
|
||||
|
||||
type Int32ConfigOption struct {
|
||||
Value int32 `gorm:"column:v"`
|
||||
Overridable bool `gorm:"column:o"`
|
||||
}
|
||||
|
||||
func (o Int32ConfigOption) GetValue() int32 {
|
||||
return o.Value
|
||||
}
|
||||
|
||||
func (o *Int32ConfigOption) SetValue(value int32) {
|
||||
o.Value = value
|
||||
}
|
||||
|
||||
func (o *Int32ConfigOption) TrySetValue(value int32) bool {
|
||||
if o.Overridable {
|
||||
o.Value = value
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func NewInt32ConfigOption(value int32, overridable bool) Int32ConfigOption {
|
||||
return Int32ConfigOption{
|
||||
Value: value,
|
||||
Overridable: overridable,
|
||||
}
|
||||
}
|
||||
|
||||
type BoolConfigOption struct {
|
||||
Value bool `gorm:"column:v"`
|
||||
Overridable bool `gorm:"column:o"`
|
||||
}
|
||||
|
||||
func (o BoolConfigOption) GetValue() bool {
|
||||
return o.Value
|
||||
}
|
||||
|
||||
func (o *BoolConfigOption) SetValue(value bool) {
|
||||
o.Value = value
|
||||
}
|
||||
|
||||
func (o *BoolConfigOption) TrySetValue(value bool) bool {
|
||||
if o.Overridable {
|
||||
o.Value = value
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func NewBoolConfigOption(value bool, overridable bool) BoolConfigOption {
|
||||
return BoolConfigOption{
|
||||
Value: value,
|
||||
Overridable: overridable,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user