]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
doc: major docs restructuring
authorPetr Špaček <petr.spacek@nic.cz>
Fri, 3 Jan 2020 19:32:29 +0000 (20:32 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Wed, 15 Jan 2020 09:38:16 +0000 (10:38 +0100)
daemon/README.rst
daemon/bindings/modules.rst
daemon/lua/trust_anchors.rst
daemon/scripting.rst
doc/config.rst
doc/index.rst
doc/modules.rst [deleted file]
doc/startguide.rst

index 313c3e93eb10c467c0ae3f8a0d80416fb0b3514d..de29f9d188b543e85314e81de5811a94c2aef3f8 100644 (file)
@@ -1,74 +1,7 @@
 .. _daemon:
 
-Daemon
-======
-
-The server is in the `daemon` directory, it works out of the box without any configuration.
-
-.. code-block:: bash
-
-   $ kresd -v  # run with defaults in verbose mode
-   $ kresd -h  # Get help
-
-If you're using our packages, they also provide systemd integration. To start the resolver under systemd, you can use the ``kresd@1.service`` service. By default, the resolver only binds to local interfaces.
-
-.. code-block:: bash
-
-   $ man kresd.systemd  # Help for systemd integration configuration
-   $ systemctl start kresd@1.service
-
-
-Configuration
--------------
-
-.. contents::
-   :depth: 2
-   :local:
-
-In its simplest form the server requires just a working directory in which it can set up persistent files like
-cache and the process state. If you don't provide the working directory by parameter, it is going to make itself
-comfortable in the current working directory.
-
-.. code-block:: sh
-
-       $ kresd /var/cache/knot-resolver
-
-And you're good to go for most use cases! If you want to use modules or configure daemon behavior, read on.
-
-There are several choices on how you can configure the daemon, a RPC interface, a CLI, and a configuration file.
-Fortunately all share common syntax and are transparent to each other.
-
-
-Configuration reference
------------------------
-
-This is a reference for variables and functions available to both configuration file and CLI.
-
-.. contents::
-   :depth: 1
-   :local:
-
-Environment
-^^^^^^^^^^^
-
-.. envvar:: env (table)
-
-   Return environment variable.
-
-   .. code-block:: lua
-
-       env.USER -- equivalent to $USER in shell
-
-.. function:: hostname([fqdn])
-
-   :return: Machine hostname.
-
-   If called with a parameter, it will set kresd's internal
-   hostname. If called without a parameter, it will return kresd's
-   internal hostname, or the system's POSIX hostname (see
-   gethostname(2)) if kresd's internal hostname is unset.
-
-   This affects ephemeral certificates for kresd serving DNS over TLS.
+TODO: Environment
+=================
 
 .. function:: verbose(true | false)
 
@@ -133,98 +66,7 @@ Environment
       > user('root')
       Operation not permitted
 
-.. function:: resolve(name, type[, class = kres.class.IN, options = {}, finish = nil, init = nil])
-
-   :param string name: Query name (e.g. 'com.')
-   :param number type: Query type (e.g. ``kres.type.NS``)
-   :param number class: Query class *(optional)* (e.g. ``kres.class.IN``)
-   :param strings options: Resolution options (see :c:type:`kr_qflags`)
-   :param function finish: Callback to be executed when resolution completes (e.g. `function cb (pkt, req) end`). The callback gets a packet containing the final answer and doesn't have to return anything.
-   :param function init: Callback to be executed with the :c:type:`kr_request` before resolution starts.
-   :return: boolean
-
-   The function can also be executed with a table of arguments instead. This is useful if you'd like to skip some arguments, for example:
-
-   .. code-block:: lua
-
-      resolve {
-         name = 'example.com',
-         type = kres.type.AAAA,
-         init = function (req)
-         end,
-      }
-
-   Example:
-
-   .. code-block:: lua
-
-      -- Send query for root DNSKEY, ignore cache
-      resolve('.', kres.type.DNSKEY, kres.class.IN, 'NO_CACHE')
-
-      -- Query for AAAA record
-      resolve('example.com', kres.type.AAAA, kres.class.IN, 0,
-      function (pkt, req)
-         -- Check answer RCODE
-         if pkt:rcode() == kres.rcode.NOERROR then
-            -- Print matching records
-            local records = pkt:section(kres.section.ANSWER)
-            for i = 1, #records do
-               local rr = records[i]
-               if rr.type == kres.type.AAAA then
-                  print ('record:', kres.rr2str(rr))
-               end
-            end
-         else
-            print ('rcode: ', pkt:rcode())
-         end
-      end)
-
-.. function:: package_version()
-
-   :return: Current package version.
-
-   This returns current package version (the version of the binary) as a string.
-
-      .. code-block:: lua
-
-         > package_version()
-         2.1.1
-
-
-.. include:: ../daemon/bindings/modules.rst
-
-CLI interface
-=============
-
-The daemon features a CLI interface, type ``help()`` to see the list of available commands.
-
-.. code-block:: bash
-
-   $ kresd /var/cache/knot-resolver
-   [system] started in interactive mode, type 'help()'
-   > cache.count()
-   53
-
-.. role:: lua(code)
-   :language: lua
-
-Verbose output
---------------
-
-If the verbose logging is compiled in, i.e. not turned off by
-``verbose_log=disabled``, you can turn on verbose tracing of server operation
-with the ``-v`` option.  You can also toggle it on runtime with
-``verbose(true|false)`` command.
-
-.. code-block:: bash
-
-   $ kresd -v
-
-To run the daemon by hand, such as under ``nohup``, use ``-f 1`` to start a single fork. For example:
-
-.. code-block:: bash
 
-   $ nohup ./daemon/kresd -a 127.0.0.1 -f 1 -v &
 
 .. _`JSON-encoded`: http://json.org/example
 .. _`Learn Lua in 15 minutes`: http://tylerneylon.com/a/learn-lua/
@@ -235,4 +77,3 @@ To run the daemon by hand, such as under ``nohup``, use ``-f 1`` to start a sing
 .. _`real process managers`: http://blog.crocodoc.com/post/48703468992/process-managers-the-good-the-bad-and-the-ugly
 .. _`socket activation`: http://0pointer.de/blog/projects/socket-activation.html
 .. _`dnsproxy module`: https://www.knot-dns.cz/docs/2.7/html/modules.html#dnsproxy-tiny-dns-proxy
-.. _`lua-http`: https://luarocks.org/modules/daurnimator/http
index 8eb332777bb94d4b31b5d1b4755c271d9051f129..de554e99f2ad36f0f59e2cc6de535bc678539ca3 100644 (file)
@@ -1,8 +1,8 @@
 
-Modules configuration
-^^^^^^^^^^^^^^^^^^^^^
+TODO: Modules configuration
+===========================
 
-The daemon provides an interface for dynamic loading of :ref:`daemon modules <modules-implemented>`.
+The daemon provides an interface for dynamic loading of daemon modules.
 
 .. tip:: Use declarative interface for module loading.
 
index 369ee630402be7aab5a37383aa47258ed3e6875c..68962ff59437119bc6acac06a01ad4c4a3bad745 100644 (file)
@@ -25,6 +25,8 @@ policy, or automatically maintained by the resolver itself.
 In practice this means that you can forget about it and your favorite Linux
 distribution will take care of it for you.
 
+Following functions allow to modify DNSSEC configuration *if you really have to*:
+
 
 .. function:: trust_anchors.add_file(keyfile[, readonly = false])
 
index 1994eb015df2ba708e46f39efb93b37c3018ce6f..f2472130dee2ba39bd6ca90d7a972716b06c9f67 100644 (file)
@@ -4,11 +4,13 @@ Run-time reconfiguration
 Knot Resolver offers several ways to modify its configuration at run-time:
 
   - Using control socket driven by an external system
-  - Using Lua script embeded in Resolver's configuration file
+  - Using Lua program embeded in Resolver's configuration file
+
+Both ways can also be combined: For example the configuration file can contain a little Lua function which gathers statistics and returns them in JSON string. This can be used by an external system which uses control socket to call this user-defined function and to retrieve its results.
 
 Control sockets
 ---------------
-Control socket acts like "an interactive configuration file" so all actions available in configuration file can be executed interactively using the control socket. One possible use-case is reconfiguring Resolver instances from another program, e.g. your maintenance script.
+Control socket acts like "an interactive configuration file" so all actions available in configuration file can be executed interactively using the control socket. One possible use-case is reconfiguring Resolver instances from another program, e.g. a maintenance script.
 
 .. note::
 
@@ -33,7 +35,7 @@ There are some basic commands to start with.
    > net.list()        -- lists running network services
 
 
-The *direct output* of the CLI command is captured and sent over the socket, while also printed to the daemon standard outputs (for accountability). This gives you an immediate response on the outcome of your command.
+The *direct output* of commands sent over socket is captured and sent back, while also printed to the daemon standard outputs (in :func:`verbose` mode). This gives you an immediate response on the outcome of your command.
 Error or debug logs aren't captured, but you can find them in the daemon standard outputs.
 
 Control sockets are also a way to enumerate and test running instances, the list of sockets corresponds to the list
@@ -42,7 +44,7 @@ of processes, and you can test the process for liveliness by connecting to the U
 Lua scripts
 -----------
 
-As it was mentioned in section :ref:`config-syntax`, Resolver's configuration file contains program in Lua programming language. This allows you to write dynamic rules and helps you to avoid repetitive templating that is unavoidable with static configuration. For example parts of configuration can depend on hostname of the machine:
+As it was mentioned in section :ref:`config-syntax`, Resolver's configuration file contains program in Lua programming language. This allows you to write dynamic rules and helps you to avoid repetitive templating that is unavoidable with static configuration. For example parts of configuration can depend on :func:`hostname` of the machine:
 
 .. code-block:: lua
 
@@ -94,6 +96,119 @@ to avoid cold-cache start.
                 cache.open(cache_size, 'lmdb://' .. cache_path)
        end
 
+Helper functions
+^^^^^^^^^^^^^^^^
+Following built-in functions are useful for scripting:
+
+.. envvar:: env (table)
+
+   Retrieve environment variables.
+
+   Example:
+
+   .. code-block:: lua
+
+       env.USER -- equivalent to $USER in shell
+
+.. function:: fromjson(JSONstring)
+
+   :return: Lua representation of data in JSON string.
+
+   Example:
+
+      .. code-block:: lua
+
+        > fromjson('{"key1": "value1", "key2": {"subkey1": 1, "subkey2": 2}}')
+        [key1] => value1
+        [key2] => {
+            [subkey1] => 1
+            [subkey2] => 2
+        }
+
+
+.. function:: hostname([fqdn])
+
+   :return: Machine hostname.
+
+   If called with a parameter, it will set kresd's internal
+   hostname. If called without a parameter, it will return kresd's
+   internal hostname, or the system's POSIX hostname (see
+   gethostname(2)) if kresd's internal hostname is unset.
+
+   This also affects ephemeral (self-signed) certificates generated by kresd
+   for DNS over TLS.
+
+.. function:: package_version()
+
+   :return: Current package version as string.
+
+   Example:
+
+      .. code-block:: lua
+
+         > package_version()
+         2.1.1
+
+.. function:: resolve(name, type[, class = kres.class.IN, options = {}, finish = nil, init = nil])
+
+   :param string name: Query name (e.g. 'com.')
+   :param number type: Query type (e.g. ``kres.type.NS``)
+   :param number class: Query class *(optional)* (e.g. ``kres.class.IN``)
+   :param strings options: Resolution options (see :c:type:`kr_qflags`)
+   :param function finish: Callback to be executed when resolution completes (e.g. `function cb (pkt, req) end`). The callback gets a packet containing the final answer and doesn't have to return anything.
+   :param function init: Callback to be executed with the :c:type:`kr_request` before resolution starts.
+   :return: boolean, ``true`` if resolution was started
+
+   The function can also be executed with a table of arguments instead. This is useful if you'd like to skip some arguments, for example:
+
+   .. code-block:: lua
+
+      resolve {
+         name = 'example.com',
+         type = kres.type.AAAA,
+         init = function (req)
+         end,
+      }
+
+   Example:
+
+   .. code-block:: lua
+
+      -- Send query for root DNSKEY, ignore cache
+      resolve('.', kres.type.DNSKEY, kres.class.IN, 'NO_CACHE')
+
+      -- Query for AAAA record
+      resolve('example.com', kres.type.AAAA, kres.class.IN, 0,
+      function (pkt, req)
+         -- Check answer RCODE
+         if pkt:rcode() == kres.rcode.NOERROR then
+            -- Print matching records
+            local records = pkt:section(kres.section.ANSWER)
+            for i = 1, #records do
+               local rr = records[i]
+               if rr.type == kres.type.AAAA then
+                  print ('record:', kres.rr2str(rr))
+               end
+            end
+         else
+            print ('rcode: ', pkt:rcode())
+         end
+      end)
+
+
+.. function:: tojson(object)
+
+   :return: JSON text representation of `object`.
+
+   Example:
+
+   .. code-block:: lua
+
+      > testtable = { key1 = "value1", "key2" = { subkey1 = 1, subkey2 = 2 } }
+      > tojson(testtable)
+      {"key1":"value1","key2":{"subkey1":1,"subkey2":2}}
+
+
 .. _async-events:
 
 Asynchronous events
index 1ba47fa9418334318e63a86d759b16ffb14b42d1..7b440f73a54d28d4dbd2fb9617efa84e5bc620ec 100644 (file)
@@ -33,9 +33,6 @@ Following example sets cache size and starts listening for unencrypted and also
 .. include:: ../daemon/bindings/cache.rst
 .. include:: ../daemon/lua/trust_anchors.rst
 
-.. include:: ../daemon/README.rst
-.. include:: ../daemon/scripting.rst
-
 Multiple instances
 ==================
 
@@ -127,4 +124,58 @@ individual services for classic DNS, DoT and DoH from each other.
        panic("Use kresd@dns*, kresd@tls* or kresd@doh* instance names")
    end
 
+.. include:: ../daemon/README.rst
+.. include:: ../daemon/bindings/modules.rst
+
+Monitoring and diagnostics
+==========================
+.. contents::
+   :depth: 1
+   :local:
+.. include:: ../modules/nsid/README.rst
+.. include:: ../modules/graphite/README.rst
+.. include:: ../modules/dnstap/README.rst
+.. include:: ../modules/watchdog/README.rst
+.. include:: ../modules/bogus_log/README.rst
+.. include:: ../modules/ta_sentinel/README.rst
+.. include:: ../modules/ta_signal_query/README.rst
+.. include:: ../modules/detect_time_skew/README.rst
+.. include:: ../modules/detect_time_jump/README.rst
+
+Policy, access control, data manipulation
+=========================================
+.. include:: ../modules/hints/README.rst
+.. include:: ../modules/stats/README.rst
+.. include:: ../modules/policy/README.rst
+.. include:: ../modules/view/README.rst
+.. include:: ../modules/rebinding/README.rst
+.. include:: ../modules/refuse_nord/README.rst
+.. include:: ../modules/dns64/README.rst
+.. include:: ../modules/renumber/README.rst
+
+
+Performance and resiliency
+==========================
+.. include:: ../modules/predict/README.rst
+.. include:: ../modules/priming/README.rst
+.. include:: ../modules/rfc7706.rst
+.. include:: ../modules/prefill/README.rst
+.. include:: ../modules/serve_stale/README.rst
+.. include:: ../modules/workarounds/README.rst
+.. include:: ../modules/edns_keepalive/README.rst
+
+
+Other
+=====
+.. include:: ../modules/http/README.rst
+.. include:: ../modules/http/README.doh.rst
+.. include:: ../modules/daf/README.rst
+.. include:: ../modules/etcd/README.rst
+
+Experimental features
+=====================
+.. include:: ../modules/experimental_dot_auth/README.rst
+
+.. include:: ../daemon/scripting.rst
+
 
index e649d5898d8728fb59277895114cb9da20c7f32b..80cfc845ea0e0e2000b20356bb0bed624a8d8cfc 100644 (file)
@@ -19,7 +19,6 @@ and it provides a state-machine like API for extensions.
    :maxdepth: 2
 
    config
-   modules
 
 
 .. _operation:
diff --git a/doc/modules.rst b/doc/modules.rst
deleted file mode 100644 (file)
index 10e4a1b..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-.. _modules-implemented:
-
-*******
-Modules
-*******
-
-.. contents::
-   :depth: 1
-   :local:
-
-.. include:: ../modules/hints/README.rst
-.. include:: ../modules/stats/README.rst
-.. include:: ../modules/policy/README.rst
-.. include:: ../modules/view/README.rst
-.. include:: ../modules/predict/README.rst
-.. include:: ../modules/http/README.rst
-.. include:: ../modules/http/README.doh.rst
-.. include:: ../modules/daf/README.rst
-.. include:: ../modules/rebinding/README.rst
-.. include:: ../modules/graphite/README.rst
-.. include:: ../modules/etcd/README.rst
-.. include:: ../modules/dns64/README.rst
-.. include:: ../modules/renumber/README.rst
-.. .. include:: ../modules/cookies/README.rst
-.. include:: ../modules/bogus_log/README.rst
-.. include:: ../modules/nsid/README.rst
-.. include:: ../modules/workarounds/README.rst
-.. include:: ../modules/dnstap/README.rst
-.. include:: ../modules/ta_signal_query/README.rst
-.. include:: ../modules/ta_sentinel/README.rst
-.. include:: ../modules/priming/README.rst
-.. include:: ../modules/detect_time_skew/README.rst
-.. include:: ../modules/detect_time_jump/README.rst
-.. include:: ../modules/rfc7706.rst
-.. include:: ../modules/prefill/README.rst
-.. include:: ../modules/serve_stale/README.rst
-.. include:: ../modules/edns_keepalive/README.rst
-.. include:: ../modules/experimental_dot_auth/README.rst
-.. include:: ../modules/refuse_nord/README.rst
-.. include:: ../modules/watchdog/README.rst
index 9029983f3eda2dd0356600260718b48b94a97e6e..33210c4e44f772be2523cd2a18efcb35d986cd0f 100644 (file)
@@ -134,10 +134,6 @@ can be found `here <https://gitlab.labs.nic.cz/knot/knot-resolver/tree/master/et
 The example configuration files are also installed as documentation files, typically in directory ``/usr/share/doc/knot-resolver/examples/`` (their location may be different based on your Linux distribution).
 Detailed configuration of daemon and implemented modules can be found in configuration reference:
 
-- :ref:`Daemon configuration <daemon>`
-- :ref:`Modules configuration <modules-implemented>`
-
-
 
 Listening on network interfaces
 ===============================