mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Merge branch 'master' into tlim_newtxt
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -41,6 +42,23 @@ type recordResponse struct {
|
||||
Records []domainRecord `json:"records"`
|
||||
}
|
||||
|
||||
type domainListRecord struct {
|
||||
Domain string `json:"domain"`
|
||||
Status string `json:"status"`
|
||||
TLD string `json:"tld"`
|
||||
CreateDate string `json:"createDate"`
|
||||
ExpireDate string `json:"expireDate"`
|
||||
SecurityLock string `json:"securityLock"`
|
||||
WhoisPrivacy string `json:"whoisPrivacy"`
|
||||
AutoRenew string `json:"autoRenew"`
|
||||
NotLocal string `json:"notLocal"`
|
||||
}
|
||||
|
||||
type domainListResponse struct {
|
||||
Status string `json:"status"`
|
||||
Domains []domainListRecord `json:"domains"`
|
||||
}
|
||||
|
||||
type nsResponse struct {
|
||||
Status string `json:"status"`
|
||||
Nameservers []string `json:"ns"`
|
||||
@ -139,7 +157,15 @@ func (c *porkbunProvider) getNameservers(domain string) ([]string, error) {
|
||||
json.Unmarshal(bodyString, &ns)
|
||||
|
||||
sort.Strings(ns.Nameservers)
|
||||
return ns.Nameservers, nil
|
||||
|
||||
var nameservers []string
|
||||
for _, nameserver := range ns.Nameservers {
|
||||
// Remove the trailing dot only if it exists.
|
||||
// This provider seems to add the trailing dot to some domains but not others.
|
||||
// The .DE domains seem to always include the dot, others don't.
|
||||
nameservers = append(nameservers, strings.TrimSuffix(nameserver, "."))
|
||||
}
|
||||
return nameservers, nil
|
||||
}
|
||||
|
||||
func (c *porkbunProvider) updateNameservers(ns []string, domain string) error {
|
||||
@ -150,3 +176,21 @@ func (c *porkbunProvider) updateNameservers(ns []string, domain string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *porkbunProvider) listAllDomains() ([]string, error) {
|
||||
params := requestParams{}
|
||||
var bodyString, err = c.post("/domain/listAll", params)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed listing all domains from porkbun: %w", err)
|
||||
}
|
||||
|
||||
var dlr domainListResponse
|
||||
json.Unmarshal(bodyString, &dlr)
|
||||
|
||||
var domains []string
|
||||
for _, domain := range dlr.Domains {
|
||||
domains = append(domains, domain.Domain)
|
||||
}
|
||||
sort.Strings(domains)
|
||||
return domains, nil
|
||||
}
|
||||
|
9
providers/porkbun/listzones.go
Normal file
9
providers/porkbun/listzones.go
Normal file
@ -0,0 +1,9 @@
|
||||
package porkbun
|
||||
|
||||
func (client *porkbunProvider) ListZones() ([]string, error) {
|
||||
zones, err := client.listAllDomains()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return zones, err
|
||||
}
|
Reference in New Issue
Block a user