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.
--- 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];