Feature: support store group selected node to cache (enable by default)

This commit is contained in:
Dreamacro
2021-02-18 23:41:50 +08:00
parent aa81193d5b
commit 14bbf6eedc
6 changed files with 183 additions and 1 deletions

View File

@ -73,6 +73,11 @@ type FallbackFilter struct {
Domain []string `yaml:"domain"`
}
// Profile config
type Profile struct {
StoreSelected bool `yaml:"store-selected"`
}
// Experimental config
type Experimental struct{}
@ -82,6 +87,7 @@ type Config struct {
DNS *DNS
Experimental *Experimental
Hosts *trie.DomainTrie
Profile *Profile
Rules []C.Rule
Users []auth.AuthUser
Proxies map[string]C.Proxy
@ -129,6 +135,7 @@ type RawConfig struct {
Hosts map[string]string `yaml:"hosts"`
DNS RawDNS `yaml:"dns"`
Experimental Experimental `yaml:"experimental"`
Profile Profile `yaml:"profile"`
Proxy []map[string]interface{} `yaml:"proxies"`
ProxyGroup []map[string]interface{} `yaml:"proxy-groups"`
Rule []string `yaml:"rules"`
@ -145,7 +152,7 @@ func Parse(buf []byte) (*Config, error) {
}
func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
// config with some default value
// config with default value
rawCfg := &RawConfig{
AllowLan: false,
BindAddress: "*",
@ -169,6 +176,9 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
"8.8.8.8",
},
},
Profile: Profile{
StoreSelected: true,
},
}
if err := yaml.Unmarshal(buf, &rawCfg); err != nil {
@ -182,6 +192,7 @@ func ParseRawConfig(rawCfg *RawConfig) (*Config, error) {
config := &Config{}
config.Experimental = &rawCfg.Experimental
config.Profile = &rawCfg.Profile
general, err := parseGeneral(rawCfg)
if err != nil {