mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
Addressed code review plus missed updates
This commit is contained in:
parent
690e138164
commit
e8ce3434ee
@ -102,7 +102,7 @@ Usage of ./godns:
|
|||||||
|
|
||||||
## Config fields
|
## 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.
|
* email: Email or account name of your DNS provider.
|
||||||
* password: Password of your account.
|
* password: Password of your account.
|
||||||
* login_token: API token of your account.
|
* login_token: API token of your account.
|
||||||
@ -117,10 +117,11 @@ Usage of ./godns:
|
|||||||
|
|
||||||
Supported provider(s):
|
Supported provider(s):
|
||||||
* Cloudflare
|
* Cloudflare
|
||||||
* HE.net
|
|
||||||
* DNSPod
|
* DNSPod
|
||||||
|
* Dreamhost
|
||||||
* DuckDNS
|
* DuckDNS
|
||||||
* Google Domains
|
* Google Domains
|
||||||
|
* HE.net
|
||||||
|
|
||||||
To enable the `IPv6` mode of GoDNS, you only need two steps:
|
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.
|
* Set the `ip_type` as `IPv6`, and make sure the `ipv6_url` is configured.
|
||||||
|
@ -81,12 +81,17 @@ func (handler *Handler) UpdateIP(hostname, currentIP, lastIP string) {
|
|||||||
|
|
||||||
// updateDNS can add or remove DNS records.
|
// updateDNS can add or remove DNS records.
|
||||||
func (handler *Handler) updateDNS(dns, ip, hostname, action string) {
|
func (handler *Handler) updateDNS(dns, ip, hostname, action string) {
|
||||||
|
ipType := "A"
|
||||||
|
if strings.ToUpper(handler.Configuration.IPType) == godns.IPV6 {
|
||||||
|
ipType = "AAAA"
|
||||||
|
}
|
||||||
|
|
||||||
// Generates UUID
|
// Generates UUID
|
||||||
uid, _ := uuid.NewRandom()
|
uid, _ := uuid.NewRandom()
|
||||||
values := url.Values{}
|
values := url.Values{}
|
||||||
values.Add("record", hostname)
|
values.Add("record", hostname)
|
||||||
values.Add("key", handler.Configuration.LoginToken)
|
values.Add("key", handler.Configuration.LoginToken)
|
||||||
values.Add("type", "A")
|
values.Add("type", ipType)
|
||||||
values.Add("unique_id", uid.String())
|
values.Add("unique_id", uid.String())
|
||||||
switch action {
|
switch action {
|
||||||
case "remove":
|
case "remove":
|
||||||
|
6
utils.go
6
utils.go
@ -226,14 +226,14 @@ func CheckSettings(config *Settings) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendNotify sends notify if IP is changed
|
// SendTelegramNotify sends notify if IP is changed
|
||||||
func SendTelegramNotify(configuration *Settings, domain, currentIP string) error {
|
func SendTelegramNotify(configuration *Settings, domain, currentIP string) error {
|
||||||
if !configuration.Notify.Telegram.Enabled {
|
if !configuration.Notify.Telegram.Enabled {
|
||||||
return nil
|
return nil
|
||||||
@ -294,7 +294,7 @@ func SendTelegramNotify(configuration *Settings, domain, currentIP string) error
|
|||||||
return nil
|
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 {
|
func SendMailNotify(configuration *Settings, domain, currentIP string) error {
|
||||||
if !configuration.Notify.Mail.Enabled {
|
if !configuration.Notify.Mail.Enabled {
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user