Skip to content

Fix MX & SRV records#32

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

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

@ihmels
Copy link
Collaborator

ihmels commented Mar 16, 2026

... 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.

rr is a raw RR struct, so rr.Data is set. MX and SRV record types require special handling because the preference for MX records and the priority for SRV records must be sent to the INWX API in separate fields.

Could you provide an example where this currently leads to an issue?

@andsens
Copy link
Contributor Author

andsens commented Mar 17, 2026

You know I think this might've been a combination of me working a bit too quickly while some other bugs were tripping me up.
I think I didn't see that both record and rr was being used, where record is expected to a parsed record.

Passing parsed records to this lib works just fine. Apologies for the confusion. Closing.

@andsens andsens closed this Mar 17, 2026
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.

2 participants