util.prosodyctl.check: Reload unbound to ensure hosts.txt is ignored
authorKim Alvefur <zash@zash.se>
Sat, 03 Jul 2021 03:24:26 +0200
changeset 11649 3be346c5b940
parent 11648 fc1b8fe94d04
child 11650 b6ea0148ad37
util.prosodyctl.check: Reload unbound to ensure hosts.txt is ignored If unbound was initialized prior to this then the config change here wouldn't apply, and it will again think that 127.0.1.1 has been found in DNS.
util/prosodyctl/check.lua
--- a/util/prosodyctl/check.lua	Tue Jun 29 16:18:31 2021 +0200
+++ b/util/prosodyctl/check.lua	Sat Jul 03 03:24:26 2021 +0200
@@ -299,10 +299,12 @@
 	if not what or what == "dns" then
 		local dns = require "net.dns";
 		pcall(function ()
+			local unbound = require"net.unbound";
 			local unbound_config = configmanager.get("*", "unbound") or {};
 			unbound_config.hoststxt = false; -- don't look at /etc/hosts
 			configmanager.set("*", "unbound", unbound_config);
-			dns = require"net.unbound".dns;
+			unbound.purge(); -- ensure the above config is used
+			dns = unbound.dns;
 		end)
 		local idna = require "util.encodings".idna;
 		local ip = require "util.ip";