Allow . to be specified on stdin as well

This commit is contained in:
Andrew Ayer 2016-02-22 14:18:56 -08:00
parent 94ccbc0a4f
commit 40123f9ba8
1 changed files with 8 additions and 4 deletions

View File

@ -18,9 +18,15 @@ var watchDomainSuffixes []string
func setWatchDomains (domains []string) { func setWatchDomains (domains []string) {
for _, domain := range domains { for _, domain := range domains {
if domain == "." { // "." as in root zone (matches everything)
watchDomains = []string{}
watchDomainSuffixes = []string{""}
break
} else {
watchDomains = append(watchDomains, strings.ToLower(domain)) watchDomains = append(watchDomains, strings.ToLower(domain))
watchDomainSuffixes = append(watchDomainSuffixes, "." + strings.ToLower(domain)) watchDomainSuffixes = append(watchDomainSuffixes, "." + strings.ToLower(domain))
} }
}
} }
func dnsNameMatches (dnsName string) bool { func dnsNameMatches (dnsName string) bool {
@ -97,8 +103,6 @@ func main() {
os.Exit(3) os.Exit(3)
} }
setWatchDomains(domains) setWatchDomains(domains)
} else if flag.NArg() == 1 && flag.Arg(0) == "." { // "." as in root zone
watchDomainSuffixes = []string{""}
} else { } else {
setWatchDomains(flag.Args()) setWatchDomains(flag.Args())
} }