1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

GANDI_V5: Upgrade to newest github.com/tiramiseb/go-gandi

This commit is contained in:
Tom Limoncelli
2020-02-27 12:06:25 -05:00
committed by GitHub
parent 7c9a23b215
commit 1616c50ba7
9 changed files with 171 additions and 87 deletions

2
go.mod
View File

@ -45,7 +45,7 @@ require (
github.com/tdewolff/minify v2.3.6+incompatible
github.com/tdewolff/parse v2.3.4+incompatible // indirect
github.com/tdewolff/test v1.0.6 // indirect
github.com/tiramiseb/go-gandi v0.0.0-20200128175142-df8b8e9d23a1
github.com/tiramiseb/go-gandi v0.0.0-20200227122905-7601fc3acbaa
github.com/urfave/cli/v2 v2.1.1
github.com/vultr/govultr v0.2.0
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d // indirect

4
go.sum
View File

@ -230,8 +230,8 @@ github.com/tdewolff/parse v2.3.4+incompatible h1:x05/cnGwIMf4ceLuDMBOdQ1qGniMoxp
github.com/tdewolff/parse v2.3.4+incompatible/go.mod h1:8oBwCsVmUkgHO8M5iCzSIDtpzXOT0WXX9cWhz+bIzJQ=
github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4=
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tiramiseb/go-gandi v0.0.0-20200128175142-df8b8e9d23a1 h1:FOkGM6K21IiXFnX1UQ47yPa+awSeszBevK63k70Zggo=
github.com/tiramiseb/go-gandi v0.0.0-20200128175142-df8b8e9d23a1/go.mod h1:wevS0bE43PMSmEldbtya+tp+Ow180ftEPix8Onwh+E4=
github.com/tiramiseb/go-gandi v0.0.0-20200227122905-7601fc3acbaa h1:V0cb7c74KYakwwROlFGVlqEz3V7AW2JnIpSP6zSMdPg=
github.com/tiramiseb/go-gandi v0.0.0-20200227122905-7601fc3acbaa/go.mod h1:wevS0bE43PMSmEldbtya+tp+Ow180ftEPix8Onwh+E4=
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/vultr/govultr v0.2.0 h1:CZSNNCk+PHz9hzmfH2PFGkDgc3qNetwZqtcaqL8shlg=

View File

@ -236,7 +236,7 @@ func (client *api) GenerateDomainCorrections(dc *models.DomainConfig, existing m
&models.Correction{
Msg: msg,
F: func() error {
res, err := g.ChangeDomainRecordsWithName(domain, shortname, ns)
res, err := g.UpdateDomainRecordsByName(domain, shortname, ns)
if err != nil {
return fmt.Errorf("%+v: %w", res, err)
}

View File

@ -8,22 +8,7 @@ type Domain struct {
DomainHref string `json:"domain_href,omitempty"`
DomainKeysHref string `json:"domain_keys_href,omitempty"`
DomainRecordsHref string `json:"domain_records_href,omitempty"`
ZoneUUID string `json:"zone_uuid,omitempty"`
ZoneHref string `json:"zone_href,omitempty"`
ZoneRecordsHref string `json:"zone_records_href,omitempty"`
}
// SigningKey holds data about a DNSSEC signing key
type SigningKey struct {
Status string `json:"status,omitempty"`
UUID string `json:"uuid,omitempty"`
Algorithm int `json:"algorithm,omitempty"`
Deleted *bool `json:"deleted"`
AlgorithmName string `json:"algorithm_name,omitempty"`
FQDN string `json:"fqdn,omitempty"`
Flags int `json:"flags,omitempty"`
DS string `json:"ds,omitempty"`
KeyHref string `json:"key_href,omitempty"`
AutomaticSnapshots *bool `json:"automatic_snapshots,omitempty"`
}
type zone struct {
@ -64,39 +49,26 @@ func (g *LiveDNS) UpdateDomain(fqdn string, details UpdateDomainRequest) (respon
return
}
// DetachDomain detaches a domain from the zone it is attached to
func (g *LiveDNS) DetachDomain(fqdn string) (err error) {
_, err = g.client.Delete("domains/"+fqdn, nil, nil)
// GetDomainAXFRSecondaries returns the list of IPs that are permitted to do AXFR transfers of the domain
func (g *LiveDNS) GetDomainAXFRSecondaries(fqdn string) (secondaries []string, err error) {
_, err = g.client.Get("domains/"+fqdn+"/axfr/slaves", nil, &secondaries)
return
}
// SignDomain creates a DNSKEY and asks Gandi servers to automatically sign the domain
func (g *LiveDNS) SignDomain(fqdn string) (response client.StandardResponse, err error) {
f := SigningKey{Flags: 257}
_, err = g.client.Post("domains/"+fqdn+"/keys", f, &response)
// CreateDomainAXFRSecondary adds an IP address to the list of IPs that are permitted to do AXFR transfers of the domain
func (g *LiveDNS) CreateDomainAXFRSecondary(fqdn string, ip string) (err error) {
_, err = g.client.Put("domains/"+fqdn+"/axfr/slaves/"+ip, nil, nil)
return
}
// GetDomainKeys returns data about the signing keys created for a domain
func (g *LiveDNS) GetDomainKeys(fqdn string) (keys []SigningKey, err error) {
_, err = g.client.Get("domains/"+fqdn+"/keys", nil, &keys)
return
}
// DeleteDomainKey deletes a signing key from a domain
func (g *LiveDNS) DeleteDomainKey(fqdn, uuid string) (err error) {
_, err = g.client.Delete("domains/"+fqdn+"/keys/"+uuid, nil, nil)
return
}
// UpdateDomainKey updates a signing key for a domain (only the deleted status, actually...)
func (g *LiveDNS) UpdateDomainKey(fqdn, uuid string, deleted bool) (err error) {
_, err = g.client.Put("domains/"+fqdn+"/keys/"+uuid, SigningKey{Deleted: &deleted}, nil)
// DeleteDomainAXFRSecondary removes an IP address from the list of IPs that are permitted to do AXFR transfers of the domain
func (g *LiveDNS) DeleteDomainAXFRSecondary(fqdn string, ip string) (response client.StandardResponse, err error) {
_, err = g.client.Delete("domains/"+fqdn+"/axfr/slaves/"+ip, nil, &response)
return
}
// GetDomainNS returns the list of the nameservers for a domain
func (g *LiveDNS) GetDomainNS(fqdn string) (ns []string, err error) {
_, err = g.client.Get("nameservers/"+fqdn, nil, &ns)
_, err = g.client.Get("domains/"+fqdn+"/nameservers", nil, &ns)
return
}

View File

@ -24,14 +24,14 @@ func (g *LiveDNS) ListDomainRecordsAsText(uuid string) ([]byte, error) {
return content, err
}
// ListDomainRecordsWithName lists all records with a specific name in a zone
func (g *LiveDNS) ListDomainRecordsWithName(fqdn, name string) (records []DomainRecord, err error) {
// ListDomainRecordsByName lists all records with a specific name in a zone
func (g *LiveDNS) ListDomainRecordsByName(fqdn, name string) (records []DomainRecord, err error) {
_, err = g.client.Get("domains/"+fqdn+"/records/"+name, nil, &records)
return
}
// GetDomainRecordWithNameAndType gets the record with specific name and type in the zone attached to the domain
func (g *LiveDNS) GetDomainRecordWithNameAndType(fqdn, name, recordtype string) (record DomainRecord, err error) {
// GetDomainRecordByNameAndType gets the record with specific name and type in the zone attached to the domain
func (g *LiveDNS) GetDomainRecordByNameAndType(fqdn, name, recordtype string) (record DomainRecord, err error) {
_, err = g.client.Get("domains/"+fqdn+"/records/"+name+"/"+recordtype, nil, &record)
return
}
@ -53,24 +53,25 @@ type itemsPrefixForZoneRecords struct {
Items []DomainRecord `json:"items"`
}
// ChangeDomainRecords changes all records in the zone attached to a domain
func (g *LiveDNS) ChangeDomainRecords(fqdn string, records []DomainRecord) (response client.StandardResponse, err error) {
// UpdateDomainRecords changes all records in the zone attached to a domain
func (g *LiveDNS) UpdateDomainRecords(fqdn string, records []DomainRecord) (response client.StandardResponse, err error) {
prefixedRecords := itemsPrefixForZoneRecords{Items: records}
_, err = g.client.Put("domains/"+fqdn+"/records", prefixedRecords, &response)
return
}
// ChangeDomainRecordsWithName changes all records with the given name in the zone attached to the domain
func (g *LiveDNS) ChangeDomainRecordsWithName(fqdn, name string, records []DomainRecord) (response client.StandardResponse, err error) {
// UpdateDomainRecordsByName changes all records with the given name in the zone attached to the domain
func (g *LiveDNS) UpdateDomainRecordsByName(fqdn, name string, records []DomainRecord) (response client.StandardResponse, err error) {
prefixedRecords := itemsPrefixForZoneRecords{Items: records}
_, err = g.client.Put("domains/"+fqdn+"/records/"+name, prefixedRecords, &response)
return
}
// ChangeDomainRecordWithNameAndType changes the record with the given name and the given type in the zone attached to a domain
func (g *LiveDNS) ChangeDomainRecordWithNameAndType(fqdn, name, recordtype string, ttl int, values []string) (response client.StandardResponse, err error) {
// UpdateDomainRecordByNameAndType changes the record with the given name and the given type in the zone attached to a domain
func (g *LiveDNS) UpdateDomainRecordByNameAndType(fqdn, name, recordtype string, ttl int, values []string) (response client.StandardResponse, err error) {
_, err = g.client.Put("domains/"+fqdn+"/records/"+name+"/"+recordtype,
DomainRecord{
RrsetType: recordtype,
RrsetTTL: ttl,
RrsetValues: values,
},

99
vendor/github.com/tiramiseb/go-gandi/livedns/keys.go generated vendored Normal file
View File

@ -0,0 +1,99 @@
package livedns
import "github.com/tiramiseb/go-gandi/internal/client"
// SigningKey holds data about a DNSSEC signing key
type SigningKey struct {
Status string `json:"status,omitempty"`
UUID string `json:"uuid,omitempty"`
Algorithm int `json:"algorithm,omitempty"`
Deleted *bool `json:"deleted"`
AlgorithmName string `json:"algorithm_name,omitempty"`
FQDN string `json:"fqdn,omitempty"`
Flags int `json:"flags,omitempty"`
DS string `json:"ds,omitempty"`
KeyHref string `json:"key_href,omitempty"`
}
type configSamples struct {
Bind string `json:"bind,omitempty"`
Knot string `json:"knot,omitempty"`
NSD string `json:"nsd,omitempty"`
PowerDNS string `json:"powerdns,omitempty"`
}
// TSIGKey describes the TSIG key associated with an AXFR secondary
type TSIGKey struct {
KeyHREF string `json:"href,omitempty"`
ID string `json:"id,omitempty"`
KeyName string `json:"key_name,omitempty"`
Secret string `json:"secret,omitempty"`
ConfigSamples configSamples `json:"config_samples,omitempty"`
}
// GetTSIGKeys retrieves all the TSIG keys for the account
func (g *LiveDNS) GetTSIGKeys() (response []TSIGKey, err error) {
_, err = g.client.Get("axfr/tsig", nil, &response)
return
}
// GetTSIGKey retrieves the specified TSIG key
func (g *LiveDNS) GetTSIGKey(id string) (response TSIGKey, err error) {
_, err = g.client.Get("axfr/tsig/"+id, nil, &response)
return
}
// CreateTSIGKey creates a TSIG key
func (g *LiveDNS) CreateTSIGKey(fqdn string) (response TSIGKey, err error) {
_, err = g.client.Post("axfr/tsig", nil, &response)
return
}
// GetDomainTSIGKeys retrieves the specified TSIG key
func (g *LiveDNS) GetDomainTSIGKeys(fqdn string) (response []TSIGKey, err error) {
_, err = g.client.Get("domains/"+fqdn+"/axfr/tsig", nil, &response)
return
}
// AssociateTSIGKeyWithDomain retrieves the specified TSIG key
func (g *LiveDNS) AssociateTSIGKeyWithDomain(fqdn string, id string) (response client.StandardResponse, err error) {
_, err = g.client.Put("domains/"+fqdn+"/axfr/tsig/"+id, nil, &response)
return
}
// RemoveTSIGKeyFromDomain retrieves the specified TSIG key
func (g *LiveDNS) RemoveTSIGKeyFromDomain(fqdn string, id string) (err error) {
_, err = g.client.Delete("domains/"+fqdn+"/axfr/tsig/"+id, nil, nil)
return
}
// SignDomain creates a DNSKEY and asks Gandi servers to automatically sign the domain
func (g *LiveDNS) SignDomain(fqdn string) (response client.StandardResponse, err error) {
f := SigningKey{Flags: 257}
_, err = g.client.Post("domains/"+fqdn+"/keys", f, &response)
return
}
// GetDomainKeys returns data about the signing keys created for a domain
func (g *LiveDNS) GetDomainKeys(fqdn string) (keys []SigningKey, err error) {
_, err = g.client.Get("domains/"+fqdn+"/keys", nil, &keys)
return
}
// GetDomainKey deletes a signing key from a domain
func (g *LiveDNS) GetDomainKey(fqdn, uuid string) (key SigningKey, err error) {
_, err = g.client.Get("domains/"+fqdn+"/keys/"+uuid, nil, &key)
return
}
// DeleteDomainKey deletes a signing key from a domain
func (g *LiveDNS) DeleteDomainKey(fqdn, uuid string) (err error) {
_, err = g.client.Delete("domains/"+fqdn+"/keys/"+uuid, nil, nil)
return
}
// UpdateDomainKey updates a signing key for a domain (only the deleted status, actually...)
func (g *LiveDNS) UpdateDomainKey(fqdn, uuid string, deleted bool) (err error) {
_, err = g.client.Put("domains/"+fqdn+"/keys/"+uuid, SigningKey{Deleted: &deleted}, nil)
return
}

View File

@ -1,29 +0,0 @@
package livedns
import "github.com/tiramiseb/go-gandi/internal/client"
// Snapshot represents a zone snapshot
type Snapshot struct {
UUID string `json:"uuid,omitempty"`
DateCreated string `json:"date_created,omitempty"`
ZoneUUID string `json:"zone_uuid,omitempty"`
ZoneData []DomainRecord `json:"zone_data,omitempty"`
}
// ListSnapshots lists all domains
func (g *LiveDNS) ListSnapshots(fqdn string) (snapshots []Snapshot, err error) {
_, err = g.client.Get("domains/"+fqdn+"/snapshots", nil, &snapshots)
return
}
// CreateSnapshot creates a domain
func (g *LiveDNS) CreateSnapshot(fqdn string) (response client.StandardResponse, err error) {
_, err = g.client.Post("domains/"+fqdn+"/snapshots", nil, &response)
return
}
// GetSnapshot returns a domain
func (g *LiveDNS) GetSnapshot(fqdn, snapUUID string) (snapshot Snapshot, err error) {
_, err = g.client.Get("domains/"+fqdn+"/snapshots/"+snapUUID, nil, &snapshot)
return
}

View File

@ -0,0 +1,41 @@
package livedns
import (
"time"
"github.com/tiramiseb/go-gandi/internal/client"
)
// Snapshot represents a point in time record of a domain
type Snapshot struct {
Automatic *bool `json:"automatic,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
SnapshotHREF string `json:"snapshot_href,omitempty"`
ZoneData []DomainRecord `json:"zone_data,omitempty"`
}
// ListSnapshots lists all snapshots for a domain
func (g *LiveDNS) ListSnapshots(fqdn string) (snapshots []Snapshot, err error) {
_, err = g.client.Get("domains/"+fqdn+"/snapshots", nil, &snapshots)
return
}
// CreateSnapshot creates a snapshot for a domain
func (g *LiveDNS) CreateSnapshot(fqdn string) (response client.StandardResponse, err error) {
_, err = g.client.Post("domains/"+fqdn+"/snapshots", nil, &response)
return
}
// GetSnapshot returns a snapshot for a domain
func (g *LiveDNS) GetSnapshot(fqdn, snapUUID string) (snapshot Snapshot, err error) {
_, err = g.client.Get("domains/"+fqdn+"/snapshots/"+snapUUID, nil, &snapshot)
return
}
// DeleteSnapshot deletes a snapshot for a domain
func (g *LiveDNS) DeleteSnapshot(fqdn, snapUUID string) (err error) {
_, err = g.client.Delete("domains/"+fqdn+"/snapshots/"+snapUUID, nil, nil)
return
}

2
vendor/modules.txt vendored
View File

@ -239,7 +239,7 @@ github.com/tdewolff/parse
github.com/tdewolff/parse/buffer
github.com/tdewolff/parse/json
github.com/tdewolff/parse/strconv
# github.com/tiramiseb/go-gandi v0.0.0-20200128175142-df8b8e9d23a1
# github.com/tiramiseb/go-gandi v0.0.0-20200227122905-7601fc3acbaa
github.com/tiramiseb/go-gandi
github.com/tiramiseb/go-gandi/domain
github.com/tiramiseb/go-gandi/internal/client