1
0
mirror of https://github.com/taigrr/godns synced 2025-01-18 04:03:25 -08:00

add IPv6 support for Cloudflare

This commit is contained in:
Timothy
2020-02-06 10:32:45 +08:00
parent 290f6faf60
commit ad7fb64aa1
5 changed files with 46 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ import (
"log"
"net/http"
"runtime/debug"
"strings"
"time"
"github.com/TimothyYe/godns"
@@ -194,8 +195,16 @@ func (handler *Handler) getDNSRecords(zoneID string) []DNSRecord {
var empty []DNSRecord
var r DNSRecordResponse
var recordType string
req, client := handler.newRequest("GET", "/zones/"+zoneID+"/dns_records?type=A", nil)
if handler.Configuration.IPType == "" || strings.ToUpper(handler.Configuration.IPType) == godns.IPV4 {
recordType = "A"
} else if strings.ToUpper(handler.Configuration.IPType) == godns.IPV6 {
recordType = "AAAA"
}
log.Println("Querying records with type:", recordType)
req, client := handler.newRequest("GET", fmt.Sprintf("/zones/"+zoneID+"/dns_records?type=%s", recordType), nil)
resp, err := client.Do(req)
if err != nil {
log.Println("Request error:", err.Error())