Changeset

11253:919e7b962f0b

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.
author Kim Alvefur <zash@zash.se>
date Tue, 05 Jan 2021 21:40:06 +0100 (2021-01-05)
parents 11252:ba335004ca60
children 11254:613035d6e5a0
files net/unbound.lua
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/unbound.lua	Tue Jan 05 21:36:04 2021 +0100
+++ b/net/unbound.lua	Tue Jan 05 21:40:06 2021 +0100
@@ -60,7 +60,9 @@
 	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 @@
 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];