From de5e7a9c776d2d7508339159d2c7811d81882725 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 5 Jan 2021 21:40:06 +0100 Subject: net.unbound: Delay loading until server has started or first query Shouldn't need a DNS resolver until later anyways. Might even be sensible to only initialize if a query is actually attempted. --- net/unbound.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/net/unbound.lua b/net/unbound.lua index 85ae624f..c70f3965 100644 --- a/net/unbound.lua +++ b/net/unbound.lua @@ -60,7 +60,9 @@ local function initialize() unbound = libunbound.new(unbound_config); server_conn = connect_server(unbound, net_server); end -initialize(); +if prosody then + prosody.events.add_handler("server-started", initialize); +end local answer_mt = { __tostring = function(self) @@ -105,6 +107,7 @@ local function prep_answer(a) end local function lookup(callback, qname, qtype, qclass) + if not unbound then initialize(); end qtype = qtype and s_upper(qtype) or "A"; qclass = qclass and s_upper(qclass) or "IN"; local ntype, nclass = types[qtype], classes[qclass]; -- cgit v1.2.3