oh this is fun
iβm rewriting some code from C to Rust, which converts a DNS name from trie key format back to wire format, to help with fuzzing and property testing
my original version does it in three passes, 90 lines of code
github.com/fanf2/nsd/blob/faβ¦
1
4
(the original C also has some extra complexity because itβs doing a base64-style decode too, which I donβt [yet] need in the rust version)
1
the reason the C needs three passes is so that it can reverse the order of the labels in the name, from lexicographical order (big endian) in the trie key, into DNS wire format (little endian)
1
after some effort working out how to do it nicely in Rust, i have some handy support for parsing DNS names from wire format in various ways
so in my rewrite from C there only needs to be one pass, not three
1
how can i reduce it from three passes to one? I can use a temporary buffer and write out the labels in the order I see them (the reverse of what I want them to end up)
BUT hereβs the fun trick
i can stick DNS name compression pointers in between them
1
seems like you have been enjoying your forays into rust. I'm glad to hear it.
Jun 4, 2021 Β· 10:04 PM UTC
1

