REALTIMEREGISTER: Allow 0 prio for MX records (#3724)

Co-authored-by: pieterjan.eilers <pieterjan.eilers@realtimeregister.com>
This commit is contained in:
PJEilers 2025-08-13 15:10:23 +02:00 committed by GitHub
parent e79c43f6eb
commit 2b2f9d901e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -205,7 +205,7 @@ func (api *realtimeregisterAPI) createOrUpdateZone(body *Zone, url string) error
return err return err
} }
// Ugly hack for MX records with null target // Workaround for 0 prio and 'omitempty' restrictions on json marshalling
requestBody := strings.Replace(string(bodyBytes), "\"prio\":-1", "\"prio\":0", -1) requestBody := strings.Replace(string(bodyBytes), "\"prio\":-1", "\"prio\":0", -1)
_, err = api.request("POST", url, strings.NewReader(requestBody)) _, err = api.request("POST", url, strings.NewReader(requestBody))

View file

@ -279,10 +279,14 @@ func toRecord(recordConfig *models.RecordConfig) Record {
case "MX": case "MX":
if record.Content == "" { if record.Content == "" {
record.Content = "." record.Content = "."
record.Priority = -1 record.Priority = 0
} else { } else {
record.Priority = int(recordConfig.MxPreference) record.Priority = int(recordConfig.MxPreference)
} }
// Workaround for 0 prio and 'omitempty' restrictions on json marshalling
if record.Priority == 0 {
record.Priority = -1
}
case "LOC": case "LOC":
parts := strings.Fields(recordConfig.GetTargetCombined()) parts := strings.Fields(recordConfig.GetTargetCombined())
degrees1, _ := strconv.ParseUint(parts[0], 10, 32) degrees1, _ := strconv.ParseUint(parts[0], 10, 32)