MCPcopy
hub / github.com/gdy666/lucky / modify

Method modify

ddns/porkbun.go:123–161  ·  view source on GitHub ↗

修改

(record *PorkbunDomainQueryResponse, domain *ddnscore.Domain, recordType string, ipAddr string)

Source from the content-addressed store, hash-verified

121
122// 修改
123func (pb *Porkbun) modify(record *PorkbunDomainQueryResponse, domain *ddnscore.Domain, recordType string, ipAddr string) {
124
125 // 相同不修改
126 if len(record.Records) > 0 && record.Records[0].Content == ipAddr {
127 if domain.UpdateStatus == ddnscore.UpdatedFailed {
128 domain.SetDomainUpdateStatus(ddnscore.UpdatedSuccess, "")
129 } else {
130 domain.SetDomainUpdateStatus(ddnscore.UpdatedNothing, "")
131 }
132 return
133 }
134
135 var response PorkbunResponse
136
137 err := pb.request(
138 porkbunEndpoint+fmt.Sprintf("/editByNameType/%s/%s/%s", domain.DomainName, recordType, domain.SubDomain),
139 &PorkbunDomainCreateOrUpdateVO{
140 PorkbunApiKey: &PorkbunApiKey{
141 AccessKey: pb.task.DNS.ID,
142 SecretKey: pb.task.DNS.Secret,
143 },
144 PorkbunDomainRecord: &PorkbunDomainRecord{
145 Content: ipAddr,
146 Ttl: pb.TTL,
147 },
148 },
149 &response,
150 )
151
152 if err == nil && response.Status == "SUCCESS" {
153 domain.SetDomainUpdateStatus(ddnscore.UpdatedSuccess, "")
154 } else {
155 errMsg := fmt.Sprintf("更新域名解析失败:%v\n", response)
156 if err != nil {
157 errMsg += err.Error()
158 }
159 domain.SetDomainUpdateStatus(ddnscore.UpdatedFailed, errMsg)
160 }
161}
162
163// request 统一请求接口
164func (pb *Porkbun) request(url string, data interface{}, result interface{}) (err error) {

Callers 1

createUpdateDomainMethod · 0.95

Calls 2

requestMethod · 0.95
SetDomainUpdateStatusMethod · 0.45

Tested by

no test coverage detected