(recordType, ipAddr string, domain *ddnscore.Domain)
| 59 | } |
| 60 | |
| 61 | func (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 | // 创建 |
| 91 | func (pb *Porkbun) create(domain *ddnscore.Domain, recordType string, ipAddr string) { |
nothing calls this directly
no test coverage detected