Improvements
------------
- hints module: allow configuring the TTL and change default from 0 to 5s
+- policy module: policy.rpz() will watch the file for changes by default
+- packaging: lua cqueues added to default dependencies where available
Knot Resolver 3.2.1 (2019-01-10)
:param action: the default action for match in the zone; typically you want ``policy.DENY``
:param path: path to zone file | database
- :param watch: boolean, if true the file will be reparsed and the ruleset reloaded on file change
+ :param watch: boolean, if not false, the file will be reparsed and the ruleset reloaded on file change
Enforce RPZ_ rules. This can be used in conjunction with published blocklist feeds.
The RPZ_ operation is well described in this `Jan-Piet Mens's post`_,
rules[name] = action_map[name_action]
-- Warn when NYI
if #name > 1 and not action_map[name_action] then
- print(string.format('[ rpz ] %s:%d: unsupported policy action', path, tonumber(parser.line_counter)))
+ log('[poli] RPZ %s:%d: unsupported policy action', path, tonumber(parser.line_counter))
end
end
collectgarbage()
return rules
end
+-- Split path into dirname and basename (like the shell utilities)
local function get_dir_and_file(path)
local dir, file = string.match(path, "(.*)/([^/]+)")
function policy.rpz(action, path, watch)
local rules = rpz_parse(action, path)
- if watch then
+ if watch or true then
local has_notify, notify = pcall(require, 'cqueues.notify')
if has_notify then
local bit = require('bit')
-- Watcher will also fire for changes to the directory itself
if name == file then
-- If the file changes then reparse and replace the existing ruleset
+ if verbose() then
+ log('[poli] RPZ reloading: ' .. name)
+ end
rules = rpz_parse(action, path)
end
end
end)
- else
+ elseif watch then -- explicitly requested and failed
+ error('[poli] lua-cqueues required to watch and reload RPZ file')
+ elseif verbose() then
log('[poli] lua-cqueues required to watch and reload RPZ file, continuing without watching')
end
end