Skip to content

Fix MX & SRV records#32

Open
andsens wants to merge 3 commits intolibdns:mainfrom
orbit-online:fix-mx-srv-records
Open

Fix MX & SRV records#32
andsens wants to merge 3 commits intolibdns:mainfrom
orbit-online:fix-mx-srv-records

Conversation

@andsens
Copy link
Contributor

@andsens andsens commented Mar 10, 2026

Based on #30.

I honestly am not quite sure how this worked before. This function:

inwx/provider.go

Lines 232 to 252 in ab63b13

func inwxRecord(record libdns.Record) nameserverRecord {
rr := record.RR()
inwxRecord := nameserverRecord{
Name: rr.Name,
Type: rr.Type,
Content: rr.Data,
TTL: int(rr.TTL.Seconds()),
}
switch rec := record.(type) {
case libdns.MX:
inwxRecord.Content = rec.Target
inwxRecord.Priority = uint(rec.Preference)
case libdns.SRV:
inwxRecord.Content = fmt.Sprintf("%d %d %s", rec.Weight, rec.Port, rec.Target)
inwxRecord.Priority = uint(rec.Priority)
}
return inwxRecord
}

... expects rr.Data to be set, which is only the case for raw RR structs. But then, when checking whether it's an MX or SRV exactly the opposite is assumed.
So I'm pretty sure that anyone using this either never or exclusively uses MX and SRV records.

Here's the libdns RR struct https://github.com/libdns/libdns/blob/d3609c6996e67a8186b81cb4c797dd8c48d5017c/record.go#L111-L114

And here's the MX struct https://github.com/libdns/libdns/blob/d3609c6996e67a8186b81cb4c797dd8c48d5017c/rrtypes.go#L114-L132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant