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

CLOUDNS: Fetch permitted TTL values from API #1078 (#1102)

The TTL values permitted may be different for each account and for each domain. Therefore we perform this query once per domain.

* Fetch ClouDNS allowed TTL values from API (Fix #1078)
* Add get available TTL values comment
This commit is contained in:
2021-03-22 22:47:29 +09:00
committed by GitHub
parent 8249f33913
commit 4eb6fdface
2 changed files with 20 additions and 17 deletions

View File

@ -71,21 +71,7 @@ type domainRecord struct {
type recordResponse map[string]domainRecord
var allowedTTLValues = []uint32{
60, // 1 minute
300, // 5 minutes
900, // 15 minutes
1800, // 30 minutes
3600, // 1 hour
21600, // 6 hours
43200, // 12 hours
86400, // 1 day
172800, // 2 days
259200, // 3 days
604800, // 1 week
1209600, // 2 weeks
2419200, // 4 weeks
}
var allowedTTLValues = []uint32{}
func (c *cloudnsProvider) fetchAvailableNameservers() error {
c.nameserversNames = nil
@ -107,6 +93,21 @@ func (c *cloudnsProvider) fetchAvailableNameservers() error {
return nil
}
func (c *cloudnsProvider) fetchAvailableTTLValues(domain string) error {
allowedTTLValues = nil
params := requestParams{
"domain-name": domain,
}
var bodyString, err = c.get("/dns/get-available-ttl.json", params)
if err != nil {
return fmt.Errorf("failed fetching available TTL values list from ClouDNS: %s", err)
}
json.Unmarshal(bodyString, &allowedTTLValues)
return nil
}
func (c *cloudnsProvider) fetchDomainList() error {
c.domainIndex = map[string]string{}
rowsPerPage := 100