return std::shared_ptr<DNSRule>(new OrRule(a));
});
+ g_lua.writeFunction("DSTPortRule", [](uint16_t port) {
+ return std::shared_ptr<DNSRule>(new DSTPortRule(port));
+ });
+
g_lua.writeFunction("TCPRule", [](bool tcp) {
return std::shared_ptr<DNSRule>(new TCPRule(tcp));
});
uint8_t d_opcode;
};
+class DSTPortRule : public DNSRule
+{
+public:
+ DSTPortRule(uint16_t port) : d_port(port)
+ {
+ d_port_htons = htons(d_port);
+ }
+ bool matches(const DNSQuestion* dq) const override
+ {
+ return d_port_htons == dq->local->sin4.sin_port;
+ }
+ string toString() const override
+ {
+ return "dst port=="+std::to_string(d_port);
+ }
+private:
+ uint16_t d_port;
+ uint16_t d_port_htons;
+};
+
class TCPRule : public DNSRule
{
public:
:param bool tcp: Match TCP traffic. Default is true.
+.. function:: DSTPortRule(port)
+
+ Matches questions received to the destination port.
+
+ :param int port: Match destination port.
+
.. function:: TrailingDataRule()
Matches if the query has trailing data.