add validation for empty token and domain

This commit is contained in:
Balakrishnan Balasubramanian 2023-10-24 13:23:53 -04:00
parent 1fc84b3ee3
commit 89c122f270
2 changed files with 11 additions and 1 deletions

2
go.mod
View File

@ -1,6 +1,6 @@
module go.balki.me/cloudflare-dns-cli module go.balki.me/cloudflare-dns-cli
go 1.20 go 1.21
require ( require (
github.com/libdns/cloudflare v0.1.0 github.com/libdns/cloudflare v0.1.0

10
main.go
View File

@ -113,6 +113,16 @@ func main() {
flag.BoolVar(&mx, "m", mx, "Set mx record with cname value") flag.BoolVar(&mx, "m", mx, "Set mx record with cname value")
flag.Parse() flag.Parse()
if token == "" {
flag.Usage()
log.Panicln("empty cloudflare api token")
}
if domain == "" {
flag.Usage()
log.Panicln("empty domain name")
}
provider := cloudflare.Provider{APIToken: token} provider := cloudflare.Provider{APIToken: token}
zone := domain + "." zone := domain + "."