创建
(zoneID string, domain *ddnscore.Domain, recordType string, ipAddr string)
| 116 | |
| 117 | // 创建 |
| 118 | func (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 | // 修改 |
| 148 | func (cf *Cloudflare) modify(result CloudflareRecordsResp, zoneID string, domain *ddnscore.Domain, recordType string, ipAddr string) { |
no test coverage detected