These are chat archives for CZ-NIC/knot-resolver

29th
May 2017
Mike Emigh
@nakame_maiku_twitter
May 29 2017 10:12
hello, is it possible to generate an A record in a module? as an experiment i was trying to modify policy.enforce to respond with an A record of 127.0.0.1 instead of nxdomain, but answer:put doesn't seem to be doing much
Vladimír Čunát
@vcunat
May 29 2017 10:16
@nakame_maiku_twitter: there's the hints module for adding A and AAAA records (including the corresponding reverse records)
Mike Emigh
@nakame_maiku_twitter
May 29 2017 10:17
Yeah, that won't work with what I was trying to do though. I basically wanted to match a suffix, and then return 127.0.0.1 for anything matching it, and then mix that with views
I think it's just that the RRDATA section needs to be perfect for it to be sent, but having trouble figuring out the proper syntax
Vladimír Čunát
@vcunat
May 29 2017 10:38

There are more things one has to do than just answer:put(), I'm afraid. As I see it, there's currently not a "real API" in kresd for most stuff; it's mainly modules manipulating the internal structures (with help of some functions).

The code from policy.enforce for policy.DENY should be a good start. Note that it puts stuff to AUTHORITY section whereas you want to put stuff to ANSWER.

Mike Emigh
@nakame_maiku_twitter
May 29 2017 10:42
answer:rcode(kres.rcode.NOERROR)
answer:begin(kres.section.ANSWER)
answer:put('\2my\4test', 300, kres.class.IN, kres.type.A,
'\192\12\0\1\0\1\0\0\1\44\0\4\127\0\0\1')
return kres.DONE
spacing is off, but thats what i tried
with the rdata coming from what i saw in wireshark for another query
Vladimír Čunát
@vcunat
May 29 2017 10:44
Did you return kres.DONE?
Mike Emigh
@nakame_maiku_twitter
May 29 2017 10:44
yep
the answer section doesnt appear in a packet capture though
Vladimír Čunát
@vcunat
May 29 2017 10:45
That was all as a custom policy action, right?
Mike Emigh
@nakame_maiku_twitter
May 29 2017 10:46
yeah, the customer policy works when I imitate policy.DROP though
custom*
Mike Emigh
@nakame_maiku_twitter
May 29 2017 10:52
just got it working
the rdata itself just needs to be '\127\0\0\1' as the other data is filled in
and the function str2ip makes that easier
Vladimír Čunát
@vcunat
May 29 2017 10:56
Ah, right, I didn't check RDATA. For A records it's just four bytes.
answer:put returns error code, BTW, which is what you could recognize it by...
Mike Emigh
@nakame_maiku_twitter
May 29 2017 11:10
the daf module was almost there, but "rewrite" only applies if there is a response to rewrite