-- Smaller cache size
cache.size = 10 * MB
+local ffi = require('ffi')
+
function interactive_mode()
-- Listen on all interfaces (localhost would not work in Docker)
net.listen('0.0.0.0', 53, { kind = 'dns' })
-- ultra verbose log
verbose(true)
policy.add(policy.all(policy.DEBUG_ALWAYS))
- log('INFO: starting DNS query for %s %s', qname, kres.tostring.type[qtype])
+ log_debug(ffi.C.LOG_GRP_RESOLVER, 'starting DNS query for %s %s', qname, kres.tostring.type[qtype])
local starttime = cqueues.monotime()
resolve({
name = qname,
event.after(1, -- milisecond
function()
local endtime = cqueues.monotime()
- log('\nrequest finished in %f ms', (endtime - starttime) * 1000)
+ log_debug(ffi.C.LOG_GRP_RESOLVER, '\nrequest finished in %f ms', (endtime - starttime) * 1000)
os.exit()
end)
end
if qname and qtype then
qtypenum = kres.type[qtype]
if not qtypenum then
- log('ERROR: unsupported query type "%s", use TYPE12345 notation', qtype)
+ log_error(ffi.C.LOG_GRP_RESOLVER, 'ERROR: unsupported query type "%s", use TYPE12345 notation', qtype)
os.exit()
end
debug_mode(qname, qtypenum)
'stats'
}
+local ffi = require('ffi')
+
-- log statistics every second
local stat_id = event.recurrent(1 * second, function(evid)
- log(table_print(stats.list()))
+ log_info(ffi.C.LOG_GRP_STATISTICS, table_print(stats.list()))
end)
-- stop printing statistics after first minute
local slow_increment = now['answer.slow'] - previous['answer.slow']
-- if percentage of slow answers is bigger than 5%, print warning
if slow_increment / total_increment > 0.05 then
- log('WARNING! More than 5 %% of queries was slow!')
+ log_warn(ffi.C.LOG_GRP_STATISTICS, 'WARNING! More than 5 %% of queries was slow!')
end
previous = now
end