Skip to content

Commit

Permalink
dnspod format json,subDomain查询特殊处理
Browse files Browse the repository at this point in the history
  • Loading branch information
jie authored and jie committed Sep 1, 2020
1 parent bd52230 commit edd9e04
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions dns/dnspod.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (dnspod *Dnspod) create(result DnspodRecordListResp, domain *Domain, record
"record_type": {recordType},
"record_line": {"默认"},
"value": {ipAddr},
"format": {"json"},
},
domain,
)
Expand Down Expand Up @@ -123,6 +124,7 @@ func (dnspod *Dnspod) modify(result DnspodRecordListResp, domain *Domain, record
"record_line": {"默认"},
"record_id": {record.ID},
"value": {ipAddr},
"format": {"json"},
},
domain,
)
Expand All @@ -148,14 +150,23 @@ func (dnspod *Dnspod) commonRequest(apiAddr string, values url.Values, domain *D

// 获得域名记录列表
func (dnspod *Dnspod) getRecordList(domain *Domain, typ string) (result DnspodRecordListResp, err error) {
values := url.Values{
"login_token": {dnspod.DNSConfig.ID + "," + dnspod.DNSConfig.Secret},
"domain": {domain.DomainName},
"record_type": {typ},
"format": {"json"},
}

// dnspod SubDomain 为空是@, 此处查询需要特殊处理
if domain.SubDomain != "" {
values.Add("sub_domain", domain.SubDomain)
} else {
values.Add("sub_domain", "@")
}

resp, err := http.PostForm(
recordListAPI,
url.Values{
"login_token": {dnspod.DNSConfig.ID + "," + dnspod.DNSConfig.Secret},
"domain": {domain.DomainName},
"sub_domain": {domain.SubDomain},
"record_type": {typ},
},
values,
)

util.GetHTTPResponse(resp, recordListAPI, err, &result)
Expand Down

0 comments on commit edd9e04

Please sign in to comment.