Pull request: all: allow local non-top-level domains

Updates .

Squashed commit of the following:

commit 207eeb85caf6caee81a669302daf4e10a5b61585
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Apr 15 18:48:50 2021 +0300

    all: allow local non-top-level domains
This commit is contained in:
Ainar Garipov 2021-04-15 19:00:31 +03:00
parent a1450c5595
commit d83091fc1f
11 changed files with 128 additions and 54 deletions
internal/home

View file

@ -14,7 +14,7 @@ import (
)
// currentSchemaVersion is the current schema version.
const currentSchemaVersion = 8
const currentSchemaVersion = 9
// These aliases are provided for convenience.
type (
@ -74,6 +74,7 @@ func upgradeConfigSchema(oldVersion int, diskConf yobj) (err error) {
upgradeSchema5to6,
upgradeSchema6to7,
upgradeSchema7to8,
upgradeSchema8to9,
}
n := 0
@ -464,6 +465,43 @@ func upgradeSchema7to8(diskConf yobj) (err error) {
return nil
}
// upgradeSchema8to9 performs the following changes:
//
// # BEFORE:
// 'dns':
// 'autohost_tld': 'lan'
//
// # AFTER:
// 'dns':
// 'local_domain_name': 'lan'
//
func upgradeSchema8to9(diskConf yobj) (err error) {
log.Printf("Upgrade yaml: 8 to 9")
diskConf["schema_version"] = 9
dnsVal, ok := diskConf["dns"]
if !ok {
return nil
}
dns, ok := dnsVal.(yobj)
if !ok {
return fmt.Errorf("unexpected type of dns: %T", dnsVal)
}
autohostTLDVal := dns["autohost_tld"]
autohostTLD, ok := autohostTLDVal.(string)
if !ok {
return fmt.Errorf("undexpected type of dns.autohost_tld: %T", autohostTLDVal)
}
delete(dns, "autohost_tld")
dns["local_domain_name"] = autohostTLD
return nil
}
// TODO(a.garipov): Replace with log.Output when we port it to our logging
// package.
func funcName() string {