#YC9 DNS query failed: dns: bad rdata (SOLVED)

hey, how do you test it locally?

I’m stuck with bad data, but all previous tests are passing. Either I miss something in spec, or I have some stupid mistake

the data I’m getting:
b’\x1e\xae\x01\x00\x00\x02\x00\x00\x00\x00\x00\x00\x03abc\x11longassdomainname\x03com\x00\x00\x01\x00\x01\x03def\xc0\x10\x00\x01\x00\x01’

my response:
b’\x1e\xae\x81\x00\x00\x02\x00\x02\x00\x00\x00\x00\x03abc\x11longassdomainname\x03com\x00\x00\x01\x00\x01\x03def\x11longassdomainname\x03com\x00\x01\x00\x01\x03abc\x11longassdomainname\x03com\x00\x00\x01\x00\x01\x00\x00\x00<\x00\x04\x08\x08\x08\x08\x03def\x11longassdomainname\x03com\x00\x01\x00\x01\x00\x00\x00<\x00\x04\x08\x08\x08\x08’

or, a little more readable:
header:
\x1e\xae\x81\x00\x00\x02\x00\x02\x00\x00\x00\x00
qt1:
\x03abc\x11longassdomainname\x03com\x00\x00\x01\x00\x01
qt2:
\x03def\x11longassdomainname\x03com\x00\x01\x00\x01
rec1:
\x03abc\x11longassdomainname\x03com\x00\x00\x01\x00\x01\x00\x00\x00<\x00\x04\x08\x08\x08\x08
rec2:
\x03def\x11longassdomainname\x03com\x00\x01\x00\x01\x00\x00\x00<\x00\x04\x08\x08\x08\x08

my latest commit is here:
https://git.codecrafters.io/8ceb84c23b1a5574 (I can upload it on gh/gl/etc if you can’t pull it from there)

what am I doing wrong?

okay I finally eyeballed what was wrong:
as you can see qt1 is longer than qt2 (the same as rec2), so when I was building compressed labels I missed the null byte, terminating label sequence, and got mine one byte short.

but gosh darn the error was so confusing.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.