From 4277bfcc0ffdc9c65882a84de8a4b7febec7bb59 Mon Sep 17 00:00:00 2001 From: wjc Date: Fri, 12 Mar 2021 22:55:55 +0800 Subject: [PATCH] specify Type of new record. --- alidns.go | 7 ++++--- config.json | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/alidns.go b/alidns.go index 97cd741..10318c2 100644 --- a/alidns.go +++ b/alidns.go @@ -16,6 +16,7 @@ type Config struct { AccessKeyId string `json:"accessKeyId"` AccessSecret string `json:"accessSecret"` DomainName string `json:"domainName"` + Type string `json:"Type"` RR string `json:"RR"` } @@ -82,7 +83,7 @@ func main() { var found bool = false // find subdomain for i = 0; i < domainRecords.TotalCount; i++ { - if config.RR == domainRecords.DomainRecords.Record[i].RR { + if config.RR == domainRecords.DomainRecords.Record[i].RR && config.Type == domainRecords.DomainRecords.Record[i].Type { found = true //found subdomain record if ip == domainRecords.DomainRecords.Record[i].Value { // ip not changed fmt.Println("ip", ip, "not changed!") @@ -94,7 +95,7 @@ func main() { updateDomainRecordRequest.Scheme = "https" updateDomainRecordRequest.RecordId = domainRecords.DomainRecords.Record[i].RecordId updateDomainRecordRequest.RR = config.RR - updateDomainRecordRequest.Type = "A" + updateDomainRecordRequest.Type = config.Type updateDomainRecordRequest.Value = ip response, err := client.UpdateDomainRecord(updateDomainRecordRequest) if err != nil { @@ -118,7 +119,7 @@ func main() { addDomainRequest.DomainName = config.DomainName addDomainRequest.RR = config.RR - addDomainRequest.Type = "A" + addDomainRequest.Type = config.Type addDomainRequest.Value = ip response, err := client.AddDomainRecord(addDomainRequest) diff --git a/config.json b/config.json index 6d44f24..82cb909 100644 --- a/config.json +++ b/config.json @@ -3,5 +3,6 @@ "accessKeyId": "YOUR_ACCESS_KEY_ID", "accessSecret": "YOUR_ACCESS_SECRET", "domainName": "YOUR_DOMAIN_NAME", + "Type": "A", "RR": "@" } \ No newline at end of file