add validation for empty token and domain
This commit is contained in:
parent
1fc84b3ee3
commit
89c122f270
2
go.mod
2
go.mod
@ -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
10
main.go
@ -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 + "."
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user