return std::shared_ptr<TimedIPSetRule>(new TimedIPSetRule());
});
+ g_lua.writeFunction("PoolAvailableRule", [](std::string poolname) {
+ return std::shared_ptr<DNSRule>(new PoolAvailableRule(poolname));
+ });
+
g_lua.registerFunction<void(std::shared_ptr<TimedIPSetRule>::*)()>("clear", [](std::shared_ptr<TimedIPSetRule> tisr) {
tisr->clear();
});
boost::optional<std::string> d_value;
std::string d_tag;
};
+
+class PoolAvailableRule : public DNSRule
+{
+public:
+ PoolAvailableRule(const std::string& poolname) : d_pools(&g_pools), d_poolname(poolname)
+ {
+ }
+
+ bool matches(const DNSQuestion* dq) const override
+ {
+ return (getPool(*d_pools, d_poolname)->countServers(true) > 0);
+ }
+
+ string toString() const override
+ {
+ return "pool '" + d_poolname + "' is available";
+ }
+private:
+ mutable LocalStateHolder<pools_t> d_pools;
+ std::string d_poolname;
+};
Move the last self answered response rule to the first position.
+Function for pool related rules
+
+.. function:: PoolAvailableRule(poolname)
+
+ .. versionadded:: 1.3.3
+
+ Check whether a pool has any servers available to handle queries
+
+ :param string poolname: Pool to check
+
.. _RulesIntro:
Matching Packets (Selectors)