lua-base4 provides mechanism, derived classes provide content.
loadStream(iss);
};
+// By default no features
+void BaseLua4::getFeatures(Features &) { }
+
#if !defined(HAVE_LUA)
void BaseLua4::prepareContext() { return; }
d_lw = std::unique_ptr<LuaContext>(new LuaContext);
// lua features available
- d_lw->writeVariable("pdns_features",
- vector<pair<string, boost::variant<string,bool,int,double> > > {
- // Add key-values pairs below. Make sure you add string values explicity converted to string.
- // e.g. { "somekey", string("stringvalue") }
- // Both int and double end up as a lua number type.
- { "PR8001_devicename", true },
- });
+ Features features;
+ getFeatures(features);
+ d_lw->writeVariable("pdns_features", features);
// dnsheader
d_lw->registerFunction<int(dnsheader::*)()>("getID", [](dnsheader& dh) { return ntohs(dh.id); });
virtual void postLoad() = 0;
typedef vector<pair<string, int> > in_t;
vector<pair<string, boost::variant<int, in_t, struct timeval* > > > d_pd;
+ typedef vector<pair<string, boost::variant<string,bool,int,double> > > Features;
+ virtual void getFeatures(Features&);
};
d_gettag_ffi = d_lw->readVariable<boost::optional<gettag_ffi_t>>("gettag_ffi").get_value_or(0);
}
+void RecursorLua4::getFeatures(Features & features) {
+ // Add key-values pairs below.
+ // Make sure you add string values explicity converted to string.
+ // e.g. features.push_back(make_pair("somekey", string("stringvalue"));
+ // Both int and double end up as a lua number type.
+ features.push_back(make_pair("PR8001_devicename", true));
+}
+
void RecursorLua4::maintenance() const
{
if (d_maintenance) {
protected:
virtual void postPrepareContext() override;
virtual void postLoad() override;
+ virtual void getFeatures(Features& features) override;
private:
typedef std::function<void()> luamaintenance_t;
luamaintenance_t d_maintenance;
local tags = {}
local data = {}
-
-- make sure we can pass data around to the other hooks
data['canary'] = 'from-gettag'