Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating an RR instance with empty RDATA #1601

Open
mattias-p opened this issue Sep 3, 2024 · 0 comments
Open

Creating an RR instance with empty RDATA #1601

mattias-p opened this issue Sep 3, 2024 · 0 comments

Comments

@mattias-p
Copy link

I have a domain name and an rrtype and I want to construct a corresponding fully functional dns.RR instance with empty RDATA. This is required for dns.Msg.RemoveRRset(), and I also need to perform some other processing on these records. However, I couldn’t find any documentation on the intended way to do this.

I tried using a plain *dns.RR_Header. This mostly works since *dns.RR_Header formally implements dns.RR, but its dns.RR.copy implementation just returns nil, so dns.Copy doesn't work with such instances.

I also tried using dns.NewRR(fmt.Sprintf("%s %d IN %s", domain, ttl, dns.TypeToString[rrtype])). This also mostly works but for TXT records it seems dns.PackRR needs a larger buffer than what's reported by dns.Len.

I had a look at the source code for dns.RemoveRRset and realized that wrapping the dns.RR_Header in a dns.ANY might be a solution. So far I haven't stumbled on any surprising behaviors with this solution, but I'm not confident about its robustness either.

What is the recommended way to construct a dns.RR instance with empty RDATA?

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

No branches or pull requests

1 participant