[submodule "tests/deckard"]
path = tests/deckard
url = https://gitlab.labs.nic.cz/knot/deckard.git
+[submodule "modules/policy/lua-aho-corasick"]
+ path = modules/policy/lua-aho-corasick
+ url = https://github.com/cloudflare/lua-aho-corasick.git
$(info [$(HAS_libfstrm)] libfstrm (modules/dnstap))
$(info [$(HAS_libprotobuf-c)] libprotobuf-c (modules/dnstap))
$(info [$(HAS_protoc-c)] proto-c (modules/dnstap))
+ $(info [$(HAS_ahocorasick)] ahocorasick (modules/policy))
$(info )
# Verify required dependencies are met, as listed above
/* Save original package.path to package._path */
snprintf(l_paths, MAXPATHLEN - 1,
"if package._path == nil then package._path = package.path end\n"
- "package.path = '%s/?.lua;%s/?/init.lua;'..package._path\n",
- new_moduledir,
+ "package.path = '%1$s/?.lua;%1$s/?/init.lua;'..package._path\n"
+ "if package._cpath == nil then package._cpath = package.cpath end\n"
+ "package.cpath = '%1$s/?.so;'..package._cpath\n",
new_moduledir);
int ret = l_dobytecode(engine->L, l_paths, strlen(l_paths), "");
# Lua target definition
define lua_target
-$(1) := $$(addprefix $(2)/,$$($(1)_SOURCES))
+$(1) := $(1) $$(addprefix $(2)/,$$($(1)_SOURCES))
+$(1) : $$($(1)_DEPEND)
$(1)-clean:
ifeq ($$(strip $$($(1)_INSTALL)),)
$(1)-dist:
--- /dev/null
+Subproject commit 47df012b383a0e79b9f40c1839b1581b00ce2989
-- Requests which QNAME matches given zone list (i.e. suffix match)
function policy.suffix(action, zone_list)
- local AC = require('aho-corasick')
- local tree = AC.build(zone_list)
+ local AC = require('ahocorasick')
+ local tree = AC.create(zone_list)
return function(req, query)
local match = AC.match(tree, query:name(), false)
- if match[1] ~= nil then
+ if match ~= nil then
return action
end
return nil
-policy_SOURCES := policy.lua aho-corasick.lua
+policy_SOURCES := policy.lua lua-aho-corasick/ahocorasick.so
+policy_DEPEND := modules/policy/lua-aho-corasick/ahocorasick.so
$(call make_lua_module,policy)
+
+AHOCORASICK_DIR = modules/policy/lua-aho-corasick/
+policy-clean:
+ $(MAKE) -C $(AHOCORASICK_DIR) clean
+$(AHOCORASICK_DIR)ahocorasick.so: $(AHOCORASICK_DIR)Makefile
+ $(MAKE) -C $(AHOCORASICK_DIR) MY_CFLAGS=$(lua_CFLAGS) SO_EXT=so
\ No newline at end of file