From e8ce3434eed32a254bbbe00852aa41391bbc0fe5 Mon Sep 17 00:00:00 2001 From: Eri Bastos Date: Tue, 28 Apr 2020 18:40:04 -0400 Subject: [PATCH] Addressed code review plus missed updates --- README.md | 5 +++-- handler/dreamhost/dreamhost_handler.go | 7 ++++++- utils.go | 6 +++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7f49754..e91b5ec 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Usage of ./godns: ## Config fields -* provider: The providers that GoDNS supports, available values are: `Cloudflare`, `Google`, `DNSPod`, `AliDNS`, `HE`, `DuckDNS`. +* provider: The providers that GoDNS supports, available values are: `Cloudflare`, `Google`, `DNSPod`, `AliDNS`, `HE`, `DuckDNS`, `Dreamhost`. * email: Email or account name of your DNS provider. * password: Password of your account. * login_token: API token of your account. @@ -117,10 +117,11 @@ Usage of ./godns: Supported provider(s): * Cloudflare -* HE.net * DNSPod +* Dreamhost * DuckDNS * Google Domains +* HE.net To enable the `IPv6` mode of GoDNS, you only need two steps: * Set the `ip_type` as `IPv6`, and make sure the `ipv6_url` is configured. diff --git a/handler/dreamhost/dreamhost_handler.go b/handler/dreamhost/dreamhost_handler.go index 924f4a6..2cd400f 100644 --- a/handler/dreamhost/dreamhost_handler.go +++ b/handler/dreamhost/dreamhost_handler.go @@ -81,12 +81,17 @@ func (handler *Handler) UpdateIP(hostname, currentIP, lastIP string) { // updateDNS can add or remove DNS records. func (handler *Handler) updateDNS(dns, ip, hostname, action string) { + ipType := "A" + if strings.ToUpper(handler.Configuration.IPType) == godns.IPV6 { + ipType = "AAAA" + } + // Generates UUID uid, _ := uuid.NewRandom() values := url.Values{} values.Add("record", hostname) values.Add("key", handler.Configuration.LoginToken) - values.Add("type", "A") + values.Add("type", ipType) values.Add("unique_id", uid.String()) switch action { case "remove": diff --git a/utils.go b/utils.go index 9c95b7e..19b1fb8 100644 --- a/utils.go +++ b/utils.go @@ -226,14 +226,14 @@ func CheckSettings(config *Settings) error { } default: - return errors.New("please provide supported DNS provider: DNSPod/HE/AliDNS/Cloudflare/GoogleDomain/DuckDNS") + return errors.New("please provide supported DNS provider: DNSPod/HE/AliDNS/Cloudflare/GoogleDomain/DuckDNS/Dreamhost") } return nil } -// SendNotify sends notify if IP is changed +// SendTelegramNotify sends notify if IP is changed func SendTelegramNotify(configuration *Settings, domain, currentIP string) error { if !configuration.Notify.Telegram.Enabled { return nil @@ -294,7 +294,7 @@ func SendTelegramNotify(configuration *Settings, domain, currentIP string) error return nil } -// SendNotify sends mail notify if IP is changed +// SendMailNotify sends mail notify if IP is changed func SendMailNotify(configuration *Settings, domain, currentIP string) error { if !configuration.Notify.Mail.Enabled { return nil