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

Method create

ddns/cloudflare.go:118–145  ·  view source on GitHub ↗

创建

(zoneID string, domain *ddnscore.Domain, recordType string, ipAddr string)

Source from the content-addressed store, hash-verified

116
117// 创建
118func (cf *Cloudflare) create(zoneID string, domain *ddnscore.Domain, recordType string, ipAddr string) {
119
120 record := &CloudflareRecord{
121 Type: recordType,
122 Name: domain.String(),
123 Content: ipAddr,
124 Proxied: false,
125 TTL: cf.TTL,
126 }
127
128 var status CloudflareStatus
129 err := cf.request(
130 "POST",
131 fmt.Sprintf(zonesAPI+"/%s/dns_records", zoneID),
132 record,
133 &status,
134 )
135 if err == nil && status.Success {
136 //log.Printf("新增域名解析 %s 成功!IP: %s", domain, ipAddr)
137 domain.SetDomainUpdateStatus(ddnscore.UpdatedSuccess, "")
138 } else {
139 errMsg := fmt.Sprintf("创建域名失败:\n%v\n", status)
140 if err != nil {
141 errMsg += fmt.Sprintf(":%s", err.Error())
142 }
143 domain.SetDomainUpdateStatus(ddnscore.UpdatedFailed, errMsg)
144 }
145}
146
147// 修改
148func (cf *Cloudflare) modify(result CloudflareRecordsResp, zoneID string, domain *ddnscore.Domain, recordType string, ipAddr string) {

Callers 1

createUpdateDomainMethod · 0.95

Calls 3

requestMethod · 0.95
StringMethod · 0.65
SetDomainUpdateStatusMethod · 0.45

Tested by

no test coverage detected