config -- Avoid deleting existing dns section if someone removes schema_version from yaml file.

This commit is contained in:
Eugene Bujak 2018-12-06 00:29:38 +03:00
parent 3ad4b2864d
commit 250cc0ec0f
2 changed files with 5 additions and 2 deletions

View File

@ -72,6 +72,7 @@ var config = configuration{
{Filter: dnsfilter.Filter{ID: 3}, Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"}, {Filter: dnsfilter.Filter{ID: 3}, Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"},
{Filter: dnsfilter.Filter{ID: 4}, Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"}, {Filter: dnsfilter.Filter{ID: 4}, Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"},
}, },
SchemaVersion: currentSchemaVersion,
} }
// Loads configuration from the YAML file // Loads configuration from the YAML file

View File

@ -126,8 +126,10 @@ func upgradeSchema1to2(diskConfig *map[string]interface{}) error {
} }
} }
if _, ok := (*diskConfig)["dns"]; !ok {
(*diskConfig)["dns"] = (*diskConfig)["coredns"] (*diskConfig)["dns"] = (*diskConfig)["coredns"]
delete((*diskConfig), "coredns") delete((*diskConfig), "coredns")
}
(*diskConfig)["schema_version"] = 2 (*diskConfig)["schema_version"] = 2
return nil return nil