diff options
Diffstat (limited to 'internal/config/validate.go')
-rw-r--r-- | internal/config/validate.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/config/validate.go b/internal/config/validate.go index b9dab0f56..b2bdda960 100644 --- a/internal/config/validate.go +++ b/internal/config/validate.go @@ -23,6 +23,7 @@ import ( "fmt" "strings" + "github.com/miekg/dns" "github.com/sirupsen/logrus" ) @@ -31,10 +32,23 @@ func Validate() error { errs := []error{} // host - if GetHost() == "" { + host := GetHost() + if host == "" { errs = append(errs, fmt.Errorf("%s must be set", HostFlag())) } + // accountDomain; only check if host was set, otherwise there's no point + if host != "" { + switch ad := GetAccountDomain(); ad { + case "": + SetAccountDomain(GetHost()) + default: + if !dns.IsSubDomain(ad, host) { + errs = append(errs, fmt.Errorf("%s was %s and %s was %s, but %s is not a valid subdomain of %s", HostFlag(), host, AccountDomainFlag(), ad, host, ad)) + } + } + } + // protocol switch proto := GetProtocol(); proto { case "https": |