]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lua net.listen() tweaks (+docs)
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 17 Apr 2019 16:23:25 +0000 (18:23 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 18 Apr 2019 07:54:33 +0000 (09:54 +0200)
NEWS
daemon/bindings/net.rst
daemon/network.c
daemon/network.h

diff --git a/NEWS b/NEWS
index fe5429b154b381a4fcbe71b070082f06b425eb88..0f2d2c305def94d5f5ea71f1423104d6ecff68ad 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Incompatible changes
 - upstream packages for Debian now require systemd
 - libknot >= 2.8 is required
 - net.list() output format changed
+- net.listen() reports error when address-port pair is in use
 
 Improvements
 ------------
index 774568f745ee70ae3c91fce13b0af55d2a21deff..cd49f73d91454f3a511f970e0afd79b5c8908904 100644 (file)
@@ -104,15 +104,17 @@ configured in the config file.
 
    Enable/disable using IPv4 for contacting upstream nameservers.
 
-.. function:: net.listen(addresses, [port = 53, flags = {tls = (port == 853)}])
+.. function:: net.listen(addresses, [port = 53, { kind = 'dns' }])
 
    :return: boolean
 
    Listen on addresses; port and flags are optional.
    The addresses can be specified as a string or device,
    or a list of addresses (recursively).
-   The command can be given multiple times, but note that it silently skips
-   any addresses that have already been bound.
+   The command can be given multiple times,
+   but repeating an address-port combination is an error.
+
+   If you specify port 853, ``kind = 'tls'`` by default.
 
    Examples:
 
@@ -120,7 +122,8 @@ configured in the config file.
 
        net.listen('::1')
        net.listen(net.lo, 5353)
-       net.listen({net.eth0, '127.0.0.1'}, 53853, {tls = true})
+       net.listen({net.eth0, '127.0.0.1'}, 53853, { kind = 'tls' })
+       net.listen('::', 8453, { kind = 'webmgmt' }) -- see http module
 
 .. function:: net.close(address, [port])
 
index 925d5faf57a6ad215074e02cf72a2e9d2f1f59a8..d1a87035022d47806f5de8cf5a3d5df0da2fa915 100644 (file)
@@ -375,7 +375,7 @@ int network_listen(struct network *net, const char *addr, uint16_t port,
                return kr_error(EINVAL);
        }
        if (endpoint_get(net, addr, port, flags)) {
-               return kr_ok(); /* Already listening */
+               return kr_error(EADDRINUSE); /* Already listening */
        }
 
        /* Parse address. */
index 7da4bb737cedf96c8f68089ffeb0d793588dd099..4832f4ceb1af05fbce22ce95c7f44fa40b992757 100644 (file)
@@ -95,7 +95,7 @@ void network_deinit(struct network *net);
 
 /** Start listenting on addr#port with flags.
  * \note if we did listen on that combination already,
- *       nothing is done and kr_ok() is returned.
+ *       nothing is done and kr_error(EADDRINUSE) is returned.
  * \note there's no short-hand to listen both on UDP and TCP.
  * \note ownership of flags.* is taken on success.  TODO: non-success?
  */