lua net.listen() tweaks (+docs)

parent 57297d08
......@@ -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
------------
......
......@@ -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])
......
......@@ -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. */
......
......@@ -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?
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment