Compare commits
No commits in common. "f5730d26918fe42d7283277ad2db203864631720" and "a76eff881449c19ed036d7f5bab460dbc9edc812" have entirely different histories.
f5730d2691
...
a76eff8814
@ -5,10 +5,6 @@ CLI tool to manage cloudflare DNS records
|
||||
### Using go
|
||||
```bash
|
||||
❯ go install go.balki.me/cloudflare-dns-cli@latest
|
||||
|
||||
# Or run directly
|
||||
❯ go run go.balki.me/cloudflare-dns-cli@latest
|
||||
|
||||
```
|
||||
### Using docker
|
||||
```bash
|
||||
@ -18,7 +14,7 @@ CLI tool to manage cloudflare DNS records
|
||||
|
||||
## Features
|
||||
|
||||
1. Add/Modify `A`, `AAAA`, `CNAME`, `MX` records
|
||||
1. Add/Modify `A`, `AAAA`, `CNAME` records
|
||||
2. List/Delete records
|
||||
3. Save all records in JSON format
|
||||
|
||||
@ -34,7 +30,6 @@ Usage of cloudflare-dns-cli:
|
||||
Domain name, e.g. example.com. env var: DOMAIN
|
||||
-i value
|
||||
IP address (default 127.0.0.1)
|
||||
-m Set mx record with cname value
|
||||
-o string
|
||||
Path to save all records as json, e.g. ./records.json
|
||||
-s string
|
||||
|
20
main.go
20
main.go
@ -23,7 +23,6 @@ var (
|
||||
sub = "<UNSET>"
|
||||
path string
|
||||
del = false
|
||||
mx = false
|
||||
)
|
||||
|
||||
func genRecord() (libdns.Record, error) {
|
||||
@ -31,19 +30,11 @@ func genRecord() (libdns.Record, error) {
|
||||
ipv6 := ip.To16()
|
||||
switch {
|
||||
case cname != "":
|
||||
if mx {
|
||||
return libdns.Record{
|
||||
Type: "MX",
|
||||
Name: sub,
|
||||
Value: cname,
|
||||
}, nil
|
||||
} else {
|
||||
return libdns.Record{
|
||||
Type: "CNAME",
|
||||
Name: sub,
|
||||
Value: cname,
|
||||
}, nil
|
||||
}
|
||||
return libdns.Record{
|
||||
Type: "CNAME",
|
||||
Name: sub,
|
||||
Value: cname,
|
||||
}, nil
|
||||
case ipv4 != nil:
|
||||
return libdns.Record{
|
||||
Type: "A",
|
||||
@ -110,7 +101,6 @@ func main() {
|
||||
flag.StringVar(&cname, "c", cname, "CNAME target")
|
||||
flag.StringVar(&path, "o", path, "Path to save all records as json, e.g. ./records.json")
|
||||
flag.BoolVar(&del, "x", del, "Delete records of subdomain")
|
||||
flag.BoolVar(&mx, "m", mx, "Set mx record with cname value")
|
||||
flag.Parse()
|
||||
|
||||
provider := cloudflare.Provider{APIToken: token}
|
||||
|
Loading…
Reference in New Issue
Block a user