dnsdist: Filter on opcode, records count/type, trailing data #3936

Merged
merged 2 commits into from Jun 7, 2016

Projects

None yet

3 participants

@rgacogne
Member
rgacogne commented Jun 6, 2016
  • Add OpcodeRule() to filter on opcode + DNSOpcode.* Lua values
  • Add TrailingDataRule() to filter queries with trailing data
  • Add RecordsCountRule(section, minCount, maxCount) to match on
    the number of records in a given section
  • Add RecordsTypeCountRule(section, type, minCount, maxCount) to
    match on the number of records of type type in a given section
  • Add DNSSection.* Lua values
  • Add DNSClass.* Lua values
@rgacogne rgacogne dnsdist: Filter on opcode, records count/type, trailing data
* Add `OpcodeRule()` to filter on opcode + DNSOpcode.* Lua values
* Add `TrailingDataRule()` to filter queries with trailing data
* Add `RecordsCountRule(section, minCount, maxCount)` to match on
the number of records in a given section
* Add `RecordsTypeCountRule(section, type, minCount, maxCount)` to
match on the number of records of type `type` in a given section
* Add DNSSection.* Lua values
* Add DNSClass.* Lua values
55baa1f
@zeha zeha commented on an outdated diff Jun 6, 2016
pdns/dnsparser.cc
+ }
+ try
+ {
+ const dnsheader* dh = (const dnsheader*) packet;
+ DNSPacketMangler dpm(const_cast<char*>(packet), length);
+
+ const uint16_t qdcount = ntohs(dh->qdcount);
+ for(size_t n = 0; n < qdcount; ++n) {
+ dpm.skipLabel();
+ dpm.skipBytes(4); // qtype, qclass
+ }
+ const size_t numrecords = ntohs(dh->ancount) + ntohs(dh->nscount) + ntohs(dh->arcount);
+ for(size_t n = 0; n < numrecords; ++n) {
+ dpm.skipLabel();
+
+ /* const uint16_t dnstype */ dpm.get16BitInt();
@zeha
zeha Jun 6, 2016 Collaborator

i'd suggest not having multi-line comment syntax and actual code on the same line

@ahupowerdns ahupowerdns merged commit cead95c into PowerDNS:master Jun 7, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@rgacogne rgacogne deleted the rgacogne:dnsdist-more-filtering-options branch Jun 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment