mirror of
https://github.com/safing/portbase
synced 2025-09-02 02:29:59 +00:00
Fix config persistence
This commit is contained in:
parent
f074aa5770
commit
a842929e55
2 changed files with 16 additions and 1 deletions
|
@ -47,7 +47,7 @@ func saveConfig() error {
|
||||||
for key, option := range options {
|
for key, option := range options {
|
||||||
option.Lock()
|
option.Lock()
|
||||||
if option.activeValue != nil {
|
if option.activeValue != nil {
|
||||||
activeValues[key] = option.activeValue
|
activeValues[key] = option.activeValue.getData(option)
|
||||||
}
|
}
|
||||||
option.Unlock()
|
option.Unlock()
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,21 @@ type valueCache struct {
|
||||||
boolVal bool
|
boolVal bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (vc *valueCache) getData(opt *Option) interface{} {
|
||||||
|
switch opt.OptType {
|
||||||
|
case OptTypeBool:
|
||||||
|
return vc.boolVal
|
||||||
|
case OptTypeInt:
|
||||||
|
return vc.intVal
|
||||||
|
case OptTypeString:
|
||||||
|
return vc.stringVal
|
||||||
|
case OptTypeStringArray:
|
||||||
|
return vc.stringArrayVal
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func validateValue(option *Option, value interface{}) (*valueCache, error) { //nolint:gocyclo
|
func validateValue(option *Option, value interface{}) (*valueCache, error) { //nolint:gocyclo
|
||||||
switch v := value.(type) {
|
switch v := value.(type) {
|
||||||
case string:
|
case string:
|
||||||
|
|
Loading…
Add table
Reference in a new issue