mirror of
https://github.com/safing/portmaster
synced 2025-09-04 03:29:12 +00:00
Fix hierarchical config handling
This commit is contained in:
parent
6d6b03cac3
commit
97a8475364
3 changed files with 16 additions and 5 deletions
|
@ -5,6 +5,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/safing/portbase/config"
|
||||||
|
|
||||||
"github.com/safing/portmaster/intel/filterlists"
|
"github.com/safing/portmaster/intel/filterlists"
|
||||||
"github.com/safing/portmaster/profile/endpoints"
|
"github.com/safing/portmaster/profile/endpoints"
|
||||||
)
|
)
|
||||||
|
@ -77,20 +79,24 @@ func updateGlobalConfigProfile(ctx context.Context, data interface{}) error {
|
||||||
internalSave: true,
|
internalSave: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newConfig := make(map[string]interface{})
|
||||||
// fill profile config options
|
// fill profile config options
|
||||||
for key, value := range cfgStringOptions {
|
for key, value := range cfgStringOptions {
|
||||||
profile.Config[key] = value()
|
newConfig[key] = value()
|
||||||
}
|
}
|
||||||
for key, value := range cfgStringArrayOptions {
|
for key, value := range cfgStringArrayOptions {
|
||||||
profile.Config[key] = value()
|
newConfig[key] = value()
|
||||||
}
|
}
|
||||||
for key, value := range cfgIntOptions {
|
for key, value := range cfgIntOptions {
|
||||||
profile.Config[key] = value()
|
newConfig[key] = value()
|
||||||
}
|
}
|
||||||
for key, value := range cfgBoolOptions {
|
for key, value := range cfgBoolOptions {
|
||||||
profile.Config[key] = value()
|
newConfig[key] = value()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// expand and assign
|
||||||
|
profile.Config = config.Expand(newConfig)
|
||||||
|
|
||||||
// save profile
|
// save profile
|
||||||
err = profile.Save()
|
err = profile.Save()
|
||||||
if err != nil && lastErr == nil {
|
if err != nil && lastErr == nil {
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/safing/portbase/config"
|
||||||
|
|
||||||
"github.com/safing/portbase/database"
|
"github.com/safing/portbase/database"
|
||||||
"github.com/safing/portbase/database/query"
|
"github.com/safing/portbase/database/query"
|
||||||
"github.com/safing/portbase/database/record"
|
"github.com/safing/portbase/database/record"
|
||||||
|
@ -87,6 +89,9 @@ func (h *databaseHook) PrePut(r record.Record) (record.Record, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clean config
|
||||||
|
config.CleanHierarchicalConfig(profile.Config)
|
||||||
|
|
||||||
// prepare config
|
// prepare config
|
||||||
err = profile.prepConfig()
|
err = profile.prepConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -237,7 +237,7 @@ func (profile *Profile) addEndpointyEntry(cfgKey, newEntry string) {
|
||||||
endpointList = make([]string, 0, 1)
|
endpointList = make([]string, 0, 1)
|
||||||
}
|
}
|
||||||
endpointList = append(endpointList, newEntry)
|
endpointList = append(endpointList, newEntry)
|
||||||
profile.Config[cfgKey] = endpointList
|
config.PutValueIntoHierarchicalConfig(profile.Config, cfgKey, endpointList)
|
||||||
|
|
||||||
profile.Unlock()
|
profile.Unlock()
|
||||||
err := profile.Save()
|
err := profile.Save()
|
||||||
|
|
Loading…
Add table
Reference in a new issue