-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathremove_cmd.go
More file actions
68 lines (51 loc) · 2.1 KB
/
Copy pathremove_cmd.go
File metadata and controls
68 lines (51 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"github.com/miekg/dns"
)
func init() {
Command["remove-cdscdnskeys"] = RemoveCdscdnskeysCmd
Command["remove-csync"] = RemoveCsyncCmd
CommandHelp["remove-cdscdnskeys"] = "Remove all CDS/CDNSKEYs from signers in a group, requires <fqdn>"
CommandHelp["remove-csync"] = "Remove all CSYNCs from signers in a group, requires <fqdn>"
}
func RemoveCdscdnskeysCmd(args []string, remote bool, output *[]string) error {
if len(args) < 1 {
return fmt.Errorf("requires <fqdn>")
}
if !Config.Exists("signers:" + args[0]) {
return fmt.Errorf("group %s has no signers", args[0])
}
signers := Config.ListGet("signers:" + args[0])
cds := new(dns.CDS)
cds.Hdr = dns.RR_Header{Name: args[0], Rrtype: dns.TypeCDS, Class: dns.ClassINET, Ttl: 0}
cdnskey := new(dns.CDNSKEY)
cdnskey.Hdr = dns.RR_Header{Name: args[0], Rrtype: dns.TypeCDNSKEY, Class: dns.ClassINET, Ttl: 0}
for _, signer := range signers {
updater := GetUpdater(Config.Get("signer-type:"+signer, "nsupdate"))
if err := updater.RemoveRRset(args[0], signer, [][]dns.RR{[]dns.RR{cds}, []dns.RR{cdnskey}}, output); err != nil {
return err
}
*output = append(*output, fmt.Sprintf(" Removed CDS/CDNSKEYs from %s", signer))
}
return nil
}
func RemoveCsyncCmd(args []string, remote bool, output *[]string) error {
if len(args) < 1 {
return fmt.Errorf("requires <fqdn>")
}
if !Config.Exists("signers:" + args[0]) {
return fmt.Errorf("group %s has no signers", args[0])
}
signers := Config.ListGet("signers:" + args[0])
csync := new(dns.CSYNC)
csync.Hdr = dns.RR_Header{Name: args[0], Rrtype: dns.TypeCSYNC, Class: dns.ClassINET, Ttl: 0}
for _, signer := range signers {
updater := GetUpdater(Config.Get("signer-type:"+signer, "nsupdate"))
if err := updater.RemoveRRset(args[0], signer, [][]dns.RR{[]dns.RR{csync}}, output); err != nil {
return err
}
*output = append(*output, fmt.Sprintf(" Removed CSYNC from %s", signer))
}
return nil
}