Commit 62606a2e authored by Marek Vavruša's avatar Marek Vavruša

daemon/lua: doc cleanup, todname() call

policy has policy.todnames() for table of names
parent bbdd3771
......@@ -59,6 +59,12 @@ static int l_help(lua_State *L)
"user(name[, group])\n change process user (and group)\n"
"verbose(true|false)\n toggle verbose mode\n"
"option(opt[, new_val])\n get/set server option\n"
"resolve(name, type[, class, flags, callback])\n resolve query, callback when it's finished\n"
"todname(name)\n convert name to wire format\n"
"net\n network configuration\n"
"cache\n network configuration\n"
"modules\n modules configuration\n"
"kres\n resolver services\n"
lua_pushstring(L, help_str);
return 1;
......@@ -12,6 +12,7 @@ day = 24 * hour
kres = require('kres')
trust_anchors = require('trust_anchors')
resolve = worker.resolve
todname = kres.str2dname
-- Function aliases
-- `env.VAR returns os.getenv(VAR)`
......@@ -26,7 +26,7 @@ There are several defined actions:
* ``TC`` - set TC=1 if the request came through UDP, forcing client to retry with TCP
* ``FORWARD(ip)`` - forward query to given IP and proxy back response (stub mode)
.. note:: The module (and ``kres``) treats domain names as wire, not textual representation. So each label in name is prefixed with its length, e.g. "" equals to ``"\7example\3com"``.
.. note:: The module (and ``kres``) expects domain names in wire format, not textual representation. So each label in name is prefixed with its length, e.g. "" equals to ``"\7example\3com"``. You can use convenience function ``todname('')`` for automatic conversion.
Example configuration
......@@ -134,6 +134,20 @@ Properties
"NSDNAME", "no"
"NS-IP", "no"
.. function:: policy.todnames({name, ...})
:param: names table of domain names in textual format
Returns table of domain names in wire format converted from strings.
.. code-block:: lua
-- Convert single name
assert(todname('') == '\7example\3com\0')
-- Convert table of names
policy.todnames({'', ''})
{ '\7example\3com\0', '\2me\2cz\0' }
.. _`Aho-Corasick`:
.. _`@jgrahamc`:
.. _RPZ:
......@@ -167,10 +167,11 @@ function policy.add(policy, rule)
-- Convert list of string names to domain names
function policy.to_domains(names)
function policy.todnames(names)
for i, v in ipairs(names) do
names[i] = kres.str2dname(v)
return names
-- RFC1918 Private, local, broadcast, test and special zones
......@@ -211,7 +212,7 @@ local private_zones = {
-- @var Default rules
policy.rules = { policy.suffix_common(policy.DENY, private_zones, '\4arpa\0') }
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