Commit 7ed94014 authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

modules/daf: initial commit

parent 9f0db776
......@@ -14,6 +14,7 @@ Knot DNS Resolver modules
.. include:: ../modules/view/README.rst
.. include:: ../modules/predict/README.rst
.. include:: ../modules/http/README.rst
.. include:: ../modules/daf/README.rst
.. include:: ../modules/graphite/README.rst
.. include:: ../modules/kmemcached/README.rst
.. include:: ../modules/redis/README.rst
.. _mod-daf:
DNS Application Firewall
This module is a high-level interface for other powerful filtering modules and DNS views. It provides an easy interface to apply and monitor DNS filtering rules and a persistent memory for them. It also provides a restful service interface and an HTTP interface.
Example configuration
.. code-block:: lua
modules = { 'http', 'daf' }
local cqueues = require('cqueues')
-- Module declaration
local M = {
-- @function Public-facing API
local function api(h, stream)
print('DAF: ')
for k,v in h:each() do print(k,v) end
-- @function Publish DAF statistics
local function publish(h, ws)
local ok = true
while ok do
-- Publish stats updates periodically
local push = tojson({})
ok = ws:send(push)
-- @function Cleanup module
function M.deinit()
if http then
http.endpoints['/daf'] = nil
http.snippets['/daf'] = nil
-- @function Configure module
function M.config(conf)
if not http then error('"http" module is not loaded, cannot load DAF') end
-- Export API and data publisher
http.endpoints['/daf'] = {'application/json', api, publish}
-- Export snippet
http.snippets['/daf'] = {'Application Firewall', [[
<p>Hello world!</p>
return M
\ No newline at end of file
daf_SOURCES := daf.lua
$(call make_lua_module,daf)
......@@ -20,7 +20,8 @@ modules_TARGETS += ketcd \
predict \
dns64 \
renumber \
http \
# List of Golang modules
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment