.. 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
--- /dev/null
+.. _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' }
--- /dev/null
+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
+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)
+ cqueues.sleep(0.5)
+ end
+ ws:close()
+end
+
+-- @function Cleanup module
+function M.deinit()
+ if http then
+ http.endpoints['/daf'] = nil
+ http.snippets['/daf'] = nil
+ end
+end
+
+-- @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>
+ ]]}
+end
+
+return M
\ No newline at end of file