summaryrefslogtreecommitdiffstats
path: root/daemon/lua/config.lua
blob: 448d6dd634de598afa23ec9d3cad7a025e3bc2af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- Listen on localhost
if not next(net.list()) and not env.KRESD_NO_LISTEN then
	local ok, err = pcall(net.listen, '127.0.0.1')
	if not ok then
		error('bind to 127.0.0.1@53 '..err)
	end
	-- IPv6 loopback may fail
	ok, err = pcall(net.listen, '::1')
	if not ok and verbose() then
		print('bind to ::1@53 '..err)
	end
	-- Exit when kresd isn't listening on any interfaces
	if not next(net.list()) then
		panic('not listening on any interface, exiting...')
	end
end
-- Open cache if not set/disabled
if not cache.current_size then
	cache.size = 100 * MB
end

-- 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
	_hint_root_file()
end

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)
	else
		panic("cannot open default trust anchor file:'%s'",
		      trust_anchors.keyfile_default
		)
	end
end