isc_result_t
plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
unsigned long cfg_line, isc_mem_t *mctx, void *actx,
- ns_hooktable_t *hooktable, void **instp) {
+ ns_hooktable_t *hooktable, ns_hooksource_t source,
+ void **instp) {
async_instance_t *inst = NULL;
+ UNUSED(source);
UNUSED(parameters);
UNUSED(cfg);
UNUSED(actx);
static cfg_clausedef_t syncplugin__cfgclauses[] = {
{ "rcode", &cfg_type_astring, 0 },
+ { "source", &cfg_type_astring, 0 },
{ "firstlbl", &cfg_type_qstring, CFG_CLAUSEFLAG_OPTIONAL }
};
isc_result_t
plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
unsigned long cfgline, isc_mem_t *mctx, void *actx,
- ns_hooktable_t *hooktable, void **instp) {
+ ns_hooktable_t *hooktable, ns_hooksource_t source,
+ void **instp) {
isc_result_t result;
cfg_parser_t *parser = NULL;
cfg_obj_t *syncplugincfg = NULL;
isc_buffer_t b;
ns_hook_t hook;
syncplugin_t *inst = NULL;
+ char *sourcestr = NULL;
UNUSED(cfg);
UNUSED(actx);
+ UNUSED(source);
inst = isc_mem_get(mctx, sizeof(*inst));
*inst = (syncplugin_t){ .mctx = mctx };
strncpy(inst->firstlbl, firstlbl, len);
}
+ obj = NULL;
+ CHECK(cfg_map_get(syncplugincfg, "source", &obj));
+ sourcestr = obj->value.string.base;
+
+ if (strcmp(sourcestr, "zone") == 0) {
+ if (source != NS_HOOKSOURCE_ZONE) {
+ result = ISC_R_FAILURE;
+ goto cleanup;
+ }
+ } else if (strcmp(sourcestr, "view") == 0) {
+ if (source != NS_HOOKSOURCE_VIEW) {
+ result = ISC_R_FAILURE;
+ goto cleanup;
+ }
+ } else {
+ result = ISC_R_FAILURE;
+ goto cleanup;
+ }
+
hook = (ns_hook_t){ .action = syncplugin__hook, .action_data = inst };
ns_hook_add(hooktable, mctx, NS_QUERY_NXDOMAIN_BEGIN, &hook);
inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
};
-plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin.so" {
+plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin" {
rcode noerror;
+ source view;
};
zone "example.com" {
zone "example2.com" {
type primary;
file "example.db";
- plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin.so" {
+ plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin" {
rcode servfail;
+ source zone;
};
};
zone "example3.com" {
type primary;
file "example.db";
- plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin.so" {
+ plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin" {
rcode notimp;
+ source zone;
};
};
template exampletmpl {
type primary;
file "$name.db";
- plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin.so" {
+ plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin" {
rcode notauth;
firstlbl "skipfoo";
+ source zone;
};
};
zone "example4.com" {
template exampletmpl;
- plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin.so" {
+ plugin query "@TOP_BUILDDIR@/testlib-driver-syncplugin" {
rcode notzone;
+ source zone;
};
};