aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-01-05 21:40:06 +0100
committerKim Alvefur <zash@zash.se>2021-01-05 21:40:06 +0100
commitde5e7a9c776d2d7508339159d2c7811d81882725 (patch)
treec247df94421eea6e2bd34d5f51dc700fd3c5fcaa /net
parentc69f675965f1548a4c7b923287e184899bedfaea (diff)
downloadprosody-de5e7a9c776d2d7508339159d2c7811d81882725.tar.gz
prosody-de5e7a9c776d2d7508339159d2c7811d81882725.zip
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.
Diffstat (limited to 'net')
-rw-r--r--net/unbound.lua5
1 files changed, 4 insertions, 1 deletions
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];