HEDNS: Fix issue with domain listing on completely empty/new accounts (#1075)

* HEDNS: Fix issue with domain listing on completely empty accounts

* HEDNS: Correct typo in provider name

* HEDNS: Correct further usages of HDNS -> HEDNS

Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
Robert Blenkinsopp 2021-03-02 21:08:01 +00:00 committed by GitHub
parent 541e6027aa
commit 3e5e976766
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,7 +60,7 @@ var features = providers.DocumentationNotes{
}
func init() {
providers.RegisterDomainServiceProviderType("HEDNS", newHDNSProvider, features)
providers.RegisterDomainServiceProviderType("HEDNS", newHEDNSProvider, features)
}
var defaultNameservers = []string{
@ -93,7 +93,7 @@ type hednsProvider struct {
httpClient http.Client
}
// Record stores the HDNS specific zone and record IDs
// Record stores the HEDNS specific zone and record IDs
type Record struct {
RecordName string
RecordID uint64
@ -101,7 +101,7 @@ type Record struct {
ZoneID uint64
}
func newHDNSProvider(cfg map[string]string, _ json.RawMessage) (providers.DNSServiceProvider, error) {
func newHEDNSProvider(cfg map[string]string, _ json.RawMessage) (providers.DNSServiceProvider, error) {
username, password := cfg["username"], cfg["password"]
totpSecret, totpValue := cfg["totp-key"], cfg["totp"]
sessionFilePath := cfg["session-file-path"]
@ -167,7 +167,7 @@ func (c *hednsProvider) EnsureDomainExists(domain string) error {
return c.createDomain(domain)
}
// GetNameservers returns the default HDNS nameservers.
// GetNameservers returns the default HEDNS nameservers.
func (c *hednsProvider) GetNameservers(_ string) ([]*models.Nameserver, error) {
return models.ToNameservers(defaultNameservers)
}
@ -487,13 +487,13 @@ func (c *hednsProvider) listDomains() (map[string]uint64, error) {
return nil, err
}
// Check we can list domains
// Check there are any domains in this account
domains := make(map[string]uint64)
if document.Find("#domains_table").Size() == 0 {
return nil, fmt.Errorf("domain listing failed")
return domains, nil
}
// Find all the forward & reverse domains
domains := make(map[string]uint64)
recordsSelector := strings.Join([]string{
"#domains_table > tbody > tr > td:last-child > img", // Forward records
"#tabs-advanced .generic_table > tbody > tr > td:last-child > img", // Reverse records