-
Notifications
You must be signed in to change notification settings - Fork 921
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
dnsdist: Add Lua helpers to look into the content of DNS payloads #12022
Conversation
1edb5ca
to
236fc45
Compare
print(overlay.qname) | ||
print(overlay.qtype) | ||
print(overlay.qclass) | ||
local count = overlay:getRecordsCountInSection(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local count = overlay:getRecordsCountInSection(1) | |
local count = overlay:getRecordsCountInSection(DNSSection.Answer) |
.. method:: DNSPacketOverlay:getRecordsCountInSection(section) -> int | ||
|
||
Returns the number of records in the ANSWER (1), AUTHORITY (2) and | ||
ADDITIONAL (3) section of this packet. The number of records in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ADDITIONAL (3) section of this packet. The number of records in the | |
ADDITIONAL (3) :ref:`DNSSection` of this packet. The number of records in the |
luaCtx.registerMember<dnsheader(dnsdist::DNSPacketOverlay::*)>(std::string("dh"), [](const dnsdist::DNSPacketOverlay& overlay) { return overlay.d_header; }); | ||
|
||
luaCtx.registerFunction<uint16_t (dnsdist::DNSPacketOverlay::*)(uint8_t) const>("getRecordsCountInSection", [](const dnsdist::DNSPacketOverlay& overlay, uint8_t section) -> uint16_t { | ||
if (section > 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (section > 3) { | |
if (section > DNSResourceRecord::ADDITIONAL) { |
If it doesn't need an extra include ?
pdns/dnsdistdist/dnsdist-lua-ffi.cc
Outdated
|
||
uint16_t dnsdist_ffi_dnspacket_get_records_count_in_section(const dnsdist_ffi_dnspacket_t* packet, uint8_t section) | ||
{ | ||
if (packet == nullptr || section > 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (packet == nullptr || section > 3) { | |
if (packet == nullptr || section > DNSResourceRecord::ADDITIONAL) { |
pdns/dnsdistdist/dnsdist-lua-ffi.cc
Outdated
|
||
bool dnsdist_ffi_dnspacket_parse(const char* packet, size_t packetSize, dnsdist_ffi_dnspacket_t** out) | ||
{ | ||
if (out == nullptr || packetSize < sizeof(dnsheader)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (out == nullptr || packetSize < sizeof(dnsheader)) { | |
if (packet == nullptr || out == nullptr || packetSize < sizeof(dnsheader)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nits, but LGTM otherwise !
8beac1d
to
3230f6c
Compare
Short description
This PR provides regular and FFI bindings allowing to look at the DNS records contained in a DNS payload. There is no parsing of the rdata (content) of the DNS records, though, and at this point this is not something we want to add.
Checklist
I have: