# HG changeset patch # User Kim Alvefur # Date 1780093926 -7200 # Node ID 23f1c71b3d56fb3e17566d17eedfe14d2008dbe6 # Parent a874c3f4570a61db47d7952f33d1ede24de47c26 net.unbound: Reset and apply new config on reload Makes new configuration apply, which is otherwise somewhat tricky to do. Also merges identical conditions into one block. diff -r a874c3f4570a -r 23f1c71b3d56 net/unbound.lua --- a/net/unbound.lua Thu May 28 17:25:46 2026 +0100 +++ b/net/unbound.lua Sat May 30 00:32:06 2026 +0200 @@ -42,13 +42,6 @@ end local unbound_config; -if prosody then - local config = require"prosody.core.configmanager"; - unbound_config = add_defaults(config.get("*", "unbound")); - prosody.events.add_handler("config-reloaded", function() - unbound_config = add_defaults(config.get("*", "unbound")); - end); -end -- Note: libunbound will default to using root hints if resolvconf is unset local function connect_server(unbound, server) @@ -65,9 +58,6 @@ unbound = libunbound.new(unbound_config); server_conn = connect_server(unbound, net_server); end -if prosody then - prosody.events.add_handler("server-started", initialize); -end local answer_mt = { __tostring = function(self) @@ -181,6 +171,16 @@ return true; end +if prosody then + local config = require"prosody.core.configmanager"; + unbound_config = add_defaults(config.get("*", "unbound")); + prosody.events.add_handler("config-reloaded", function() + unbound_config = add_defaults(config.get("*", "unbound")); + purge(); + end); + prosody.events.add_handler("server-started", initialize); +end + local function not_implemented() error "not implemented"; end