Cloudflare: Fix parsing of priority field in record (fixes
@@ -368,7 +368,7 @@ type cfRecord struct {
CreatedOn time.Time `json:"created_on"`
ModifiedOn time.Time `json:"modified_on"`
Data *cfRecData `json:"data"`
- Priority uint16 `json:"priority"`
+ Priority json.Number `json:"priority"`
}
func (c *cfRecord) nativeToRecord(domain string) *models.RecordConfig {
@@ -384,7 +384,13 @@ func (c *cfRecord) nativeToRecord(domain string) *models.RecordConfig {
rc.SetLabelFromFQDN(c.Name, domain)
switch rType := c.Type; rType { // #rtype_variations
case "MX":
- if err := rc.SetTargetMX(c.Priority, c.Content); err != nil {
+ var priority uint16
+ if p, err := c.Priority.Int64(); err != nil {
+ panic(errors.Wrap(err, "error decoding priority from cloudflare record"))
+ } else {
+ priority = uint16(p)
+ }
+ if err := rc.SetTargetMX(priority, c.Content); err != nil {
panic(errors.Wrap(err, "unparsable MX record received from cloudflare"))
}
case "SRV":
