config.lua 1 KB
Newer Older
1
-- Listen on localhost
2
if not next(net.list()) and not env.KRESD_NO_LISTEN then
3
	local ok, err = pcall(net.listen, '127.0.0.1')
4
	if not ok then
5
		error('bind to 127.0.0.1@53 '..err)
6 7 8 9
	end
	-- IPv6 loopback may fail
	ok, err = pcall(net.listen, '::1')
	if not ok and verbose() then
10
		print('bind to ::1@53 '..err)
11
	end
12 13 14 15
	-- Exit when kresd isn't listening on any interfaces
	if not next(net.list()) then
		panic('not listening on any interface, exiting...')
	end
16 17 18
end
-- Open cache if not set/disabled
if not cache.current_size then
19
	cache.size = 100 * MB
20
end
21

22 23
-- If no addresses for root servers are set, load them from the default file
if require('ffi').C.kr_zonecut_is_empty(kres.context().root_hints) then
24
	_hint_root_file()
25
end
26 27 28 29

if not trust_anchors.keysets['\0'] and trust_anchors.keyfile_default then
	if io.open(trust_anchors.keyfile_default, 'r') then
		trust_anchors.config(trust_anchors.keyfile_default, true)
30
	else
31 32 33 34 35
		panic("cannot open default trust anchor file:'%s'",
		      trust_anchors.keyfile_default
		)
	end
end