the answer too, which defaults to the name of the question
* `addPolicyTag(tag)`: add a policy tag.
* `discardPolicy(policyname)`: skip the filtering policy (for example RPZ) named `policyname` for this query. This is mostly useful in the `prerpz` hook.
+* `getDH()` - Returns the DNS Header of the query or nil. A DNS header offers the following methods:
+ * `getRD()`, `getAA()`, `getAD()`, `getCD()`, `getTC()`: query these bits from the DNS Header
+ * `getRCODE()`: get the RCODE of the query
+ * `getOPCODE()`: get the OPCODE of the query
+ * `getID()`: get the ID of the query
* `getPolicyTags()`: get the current policy tags as a table of strings.
* `getRecords()`: get a table of DNS Records in this DNS Question (or answer by now)
* `setPolicyTags(tags)`: update the policy tags, taking a table of strings.
for parsing.
`remoteip` is the IP(v6) address of the requestor, `localip` is the address on which the query arrived.
-`dh` is the DNS Header of the query, and it offers the following methods:
-
-* `getRD()`, `getAA()`, `getAD()`, `getCD()`, `getRD()`, `getRD()`, `getTC()`: query these bits from the DNS Header
-* `getRCODE()`: get the RCODE of the query
-* `getOPCODE()`: get the OPCODE of the query
-* `getID()`: get the ID of the query
+`dh` is the DNS Header of the query, and it offers the same functions as the `dq.getDH()` object described above.
As an example, to filter all queries coming from 1.2.3.0/24, or with the AD bit set:
}
+boost::optional<dnsheader> RecursorLua4::DNSQuestion::getDH() const
+{
+ if (dh)
+ return *dh;
+ return boost::optional<dnsheader>();
+}
+
vector<pair<uint16_t, string> > RecursorLua4::DNSQuestion::getEDNSOptions() const
{
if(ednsOptions)
pol.d_custom = shared_ptr<DNSRecordContent>(DNSRecordContent::mastermake(QType::CNAME, 1, content));
}
);
+ d_lw->registerFunction("getDH", &DNSQuestion::getDH);
d_lw->registerFunction("getEDNSOptions", &DNSQuestion::getEDNSOptions);
d_lw->registerFunction("getEDNSOption", &DNSQuestion::getEDNSOption);
d_lw->registerFunction("getEDNSSubnet", &DNSQuestion::getEDNSSubnet);
const uint16_t qtype;
const ComboAddress& local;
const ComboAddress& remote;
+ const struct dnsheader* dh{nullptr};
const bool isTcp;
const std::vector<pair<uint16_t, string>>* ednsOptions{nullptr};
vector<DNSRecord>* currentRecords{nullptr};
void addAnswer(uint16_t type, const std::string& content, boost::optional<int> ttl, boost::optional<string> name);
void addRecord(uint16_t type, const std::string& content, DNSResourceRecord::Place place, boost::optional<int> ttl, boost::optional<string> name);
vector<pair<int,DNSRecord> > getRecords() const;
+ boost::optional<dnsheader> getDH() const;
vector<pair<uint16_t, string> > getEDNSOptions() const;
boost::optional<string> getEDNSOption(uint16_t code) const;
boost::optional<Netmask> getEDNSSubnet() const;
dq->policyTags = &dc->d_policyTags;
dq->appliedPolicy = &appliedPolicy;
dq->currentRecords = &ret;
+ dq->dh = &dc->d_mdp.d_header;
}
if(dc->d_mdp.d_qtype==QType::ANY && !dc->d_tcp && g_anyToTcp) {