summaryrefslogtreecommitdiffstats
path: root/daemon/README.rst
diff options
context:
space:
mode:
authorMarek Vavruša <marek.vavrusa@nic.cz>2015-05-07 21:41:16 +0200
committerMarek Vavruša <marek.vavrusa@nic.cz>2015-05-07 21:41:16 +0200
commit4b4bf01aa74ba873e73ed176051e4df34cac9a33 (patch)
tree8310c28ed03a1defa84a2f90761c867c24f2b201 /daemon/README.rst
parentdaemon/bindings: syntactic sugar for cache (diff)
downloadknot-resolver-4b4bf01aa74ba873e73ed176051e4df34cac9a33.tar.xz
knot-resolver-4b4bf01aa74ba873e73ed176051e4df34cac9a33.zip
daemon/lua: syntactic sugar for ‘net’
this allows list-like declaration of bound interfaces e.g. net = { ‘127.0.0.1’, net.eth0 }
Diffstat (limited to 'daemon/README.rst')
-rw-r--r--daemon/README.rst18
1 files changed, 13 insertions, 5 deletions
diff --git a/daemon/README.rst b/daemon/README.rst
index 9fa69ce6..16362a98 100644
--- a/daemon/README.rst
+++ b/daemon/README.rst
@@ -112,16 +112,16 @@ The possible simple data types are strings, integers or floats and boolean.
Dynamic configuration
^^^^^^^^^^^^^^^^^^^^^
-Knowing that the the configuration is a valid Lua script enables you to write dynamic rules, and also avoid
-additional configuration templating. One example is to differentiate between internal and external
-interfaces based on environment variable.
+Knowing that the the configuration is a Lua in disguise enables you to write dynamic rules, and also avoid
+repetition and templating. This is unavoidable with static configuration, e.g. when you want to configure
+each node a little bit differently.
.. code-block:: lua
if hostname() == 'hidden' then
- net.listen(net.eth0)
+ net.listen(net.eth0, 5353)
else
- net.listen(net.eth1.addr[1])
+ net = { '127.0.0.1', net.eth1.addr[1] }
end
Another example would show how it is possible to bind to all interfaces, using iteration.
@@ -221,6 +221,14 @@ Environment
Network configuration
^^^^^^^^^^^^^^^^^^^^^
+For when listening on ``localhost`` just doesn't cut it.
+
+.. tip:: Use declarative interface for network.
+
+ .. code-block:: lua
+
+ net = { '127.0.0.1', net.eth0, net.eth1.addr[1] }
+
.. function:: net.listen(address, [port = 53])
:return: boolean