]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
bindings/net: throw lua error ofr net.listen() failures
authorTomas Krizek <tomas.krizek@nic.cz>
Wed, 11 Dec 2019 17:07:01 +0000 (18:07 +0100)
committerPetr Špaček <petr.spacek@nic.cz>
Fri, 20 Dec 2019 14:13:49 +0000 (15:13 +0100)
To avoid configuration errors, throw a lua error and crash
if it's not possible to bind as specified in net.listen().

For special use-cases, freebind=true should be used instead.

daemon/bindings/net.c
doc/upgrading.rst

index 3a80f0120f35d1ba42b9426624d2a205644c6958..b7d9341927b4a026d4a01758eaa7f1e4386b3695 100644 (file)
@@ -224,8 +224,9 @@ static int net_listen(lua_State *L)
 
        /* Now focus on the first argument. */
        lua_settop(L, 1);
-       const bool res = net_listen_addrs(L, port, tls, kind, freebind);
-       lua_pushboolean(L, res);
+       if (!net_listen_addrs(L, port, tls, kind, freebind))
+               lua_error_p(L, "net.listen() failed to bind");
+       lua_pushboolean(L, true);
        return 1;
 }
 
index ab5601606ac8b826639d6fb5fb6228685c3d481a..c6f589d9b03878751865b30def171c2887ce4cd3 100644 (file)
@@ -5,6 +5,15 @@ Upgrading
 This section summarizes steps required for upgrade to newer Knot Resolver versions.
 We advise users to also read :ref:`release_notes` for respective versions.
 
+4.x to 5.x
+==========
+
+Configuration file
+------------------
+
+* ``net.listen()`` throws an error if it fails to bind. Use ``freebind=true`` option
+  to bind to nonlocal addresses.
+
 4.2.2 to 4.3+
 =============