This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
axfr.go
76 lines (64 loc) · 2.66 KB
/
axfr.go
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
69
70
71
72
73
74
75
76
package gandi
// Tsig contains tsig data (no kidding!)
type Tsig struct {
KeyName string `json:"key_name, omitempty"`
Secret string `json:"secret,omitempty"`
UUID string `json:"uuid,omitempty"`
AxfrTsigURL string `json:"axfr_tsig_url,omitempty"`
ConfigSamples interface{} `json:"config_samples,omitempty"`
}
// ListTsigs lists all tsigs
func (g *Gandi) ListTsigs() (tsigs []Tsig, err error) {
_, err = g.askGandi(mGET, "axfr/tsig", nil, &tsigs)
return
}
// GetTsig lists more tsig details
func (g *Gandi) GetTsig(uuid string) (tsig Tsig, err error) {
_, err = g.askGandi(mGET, "axfr/tsig/"+uuid, nil, &tsig)
return
}
// GetTsigBIND shows a BIND nameserver config, and includes the nameservers available for zone transfers
func (g *Gandi) GetTsigBIND(uuid string) ([]byte, error) {
_, content, err := g.askGandiToBytes(mGET, "axfr/tsig/"+uuid+"/config/bind", nil)
return content, err
}
// GetTsigPowerDNS shows a PowerDNS nameserver config, and includes the nameservers available for zone transfers
func (g *Gandi) GetTsigPowerDNS(uuid string) ([]byte, error) {
_, content, err := g.askGandiToBytes(mGET, "axfr/tsig/"+uuid+"/config/powerdns", nil)
return content, err
}
// GetTsigNSD shows a NSD nameserver config, and includes the nameservers available for zone transfers
func (g *Gandi) GetTsigNSD(uuid string) ([]byte, error) {
_, content, err := g.askGandiToBytes(mGET, "axfr/tsig/"+uuid+"/config/nsd", nil)
return content, err
}
// GetTsigKnot shows a Knot nameserver config, and includes the nameservers available for zone transfers
func (g *Gandi) GetTsigKnot(uuid string) ([]byte, error) {
_, content, err := g.askGandiToBytes(mGET, "axfr/tsig/"+uuid+"/config/knot", nil)
return content, err
}
// CreateTsig creates a tsig
func (g *Gandi) CreateTsig() (tsig Tsig, err error) {
_, err = g.askGandi(mPOST, "axfr/tsig", nil, &tsig)
return
}
// AddTsigToDomain adds a tsig to a domain
func (g *Gandi) AddTsigToDomain(fqdn, uuid string) (err error) {
_, err = g.askGandi(mPUT, "domains/"+fqdn+"/axfr/tsig/"+uuid, nil, nil)
return
}
// AddSlaveToDomain adds a slave to a domain
func (g *Gandi) AddSlaveToDomain(fqdn, host string) (err error) {
_, err = g.askGandi(mPUT, "domains/"+fqdn+"/axfr/slaves/"+host, nil, nil)
return
}
// ListSlavesInDomain lists slaves in a domain
func (g *Gandi) ListSlavesInDomain(fqdn string) (slaves []string, err error) {
_, err = g.askGandi(mGET, "domains/"+fqdn+"/axfr/slaves", nil, &slaves)
return
}
// DelSlaveFromDomain removes a slave from a domain
func (g *Gandi) DelSlaveFromDomain(fqdn, host string) (err error) {
_, err = g.askGandi(mDELETE, "domains/"+fqdn+"/axfr/slaves/"+host, nil, nil)
return
}