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

Method createUpdateDomain

ddns/porkbun.go:61–88  ·  view source on GitHub ↗
(recordType, ipAddr string, domain *ddnscore.Domain)

Source from the content-addressed store, hash-verified

59}
60
61func (pb *Porkbun) createUpdateDomain(recordType, ipAddr string, domain *ddnscore.Domain) {
62
63 var record PorkbunDomainQueryResponse
64 // 获取当前域名信息
65 err := pb.request(
66 porkbunEndpoint+fmt.Sprintf("/retrieveByNameType/%s/%s/%s", domain.DomainName, recordType, domain.SubDomain),
67 &PorkbunApiKey{
68 AccessKey: pb.task.DNS.ID,
69 SecretKey: pb.task.DNS.Secret,
70 },
71 &record,
72 )
73
74 if err != nil {
75 return
76 }
77 if record.Status == "SUCCESS" {
78 if len(record.Records) > 0 {
79 // 存在,更新
80 pb.modify(&record, domain, recordType, ipAddr)
81 } else {
82 // 不存在,创建
83 pb.create(domain, recordType, ipAddr)
84 }
85 } else {
86 domain.SetDomainUpdateStatus(ddnscore.UpdatedFailed, "查询现有域名记录失败")
87 }
88}
89
90// 创建
91func (pb *Porkbun) create(domain *ddnscore.Domain, recordType string, ipAddr string) {

Callers

nothing calls this directly

Calls 4

requestMethod · 0.95
modifyMethod · 0.95
createMethod · 0.95
SetDomainUpdateStatusMethod · 0.45

Tested by

no test coverage detected