diff options
author | Kim Alvefur <zash@zash.se> | 2018-09-13 21:16:37 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-09-13 21:16:37 +0200 |
commit | 3cb132326dd6489e14a26071f87d68bf277a5a70 (patch) | |
tree | b4da64794c9bc56582b28e51e1a6de21b6f7c885 /net/server_epoll.lua | |
parent | 0045fa7647f01581eab8d344f9e755f98d3aa910 (diff) | |
download | prosody-3cb132326dd6489e14a26071f87d68bf277a5a70.tar.gz prosody-3cb132326dd6489e14a26071f87d68bf277a5a70.zip |
net.server: New API for creating server listeners
server.listen(interface, port, listeners, options);
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r-- | net/server_epoll.lua | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index fdf006f6..5609f058 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -637,7 +637,7 @@ function interface:onconnect() self:on("connect"); end -local function addserver(addr, port, listeners, read_size, tls_ctx) +local function listen(addr, port, listeners, config) local conn, err = socket.bind(addr, port, cfg.tcp_backlog); if not conn then return conn, err; end conn:settimeout(0); @@ -645,10 +645,10 @@ local function addserver(addr, port, listeners, read_size, tls_ctx) conn = conn; created = gettime(); listeners = listeners; - read_size = read_size; + read_size = config and config.read_size; onreadable = interface.onacceptable; - tls_ctx = tls_ctx; - tls_direct = tls_ctx and true or false; + tls_ctx = config and config.tls_ctx; + tls_direct = config and config.tls_direct; sockname = addr; sockport = port; }, interface_mt); @@ -657,6 +657,15 @@ local function addserver(addr, port, listeners, read_size, tls_ctx) end -- COMPAT +local function addserver(addr, port, listeners, read_size, tls_ctx) + return listen(addr, port, listeners, { + read_size = read_size; + tls_ctx = tls_ctx; + tls_direct = tls_ctx and true or false; + }); +end + +-- COMPAT local function wrapclient(conn, addr, port, listeners, read_size, tls_ctx) local client = wrapsocket(conn, nil, read_size, listeners, tls_ctx); if not client.peername then @@ -792,6 +801,7 @@ return { addserver = addserver; addclient = addclient; add_task = addtimer; + listen = listen; at = at; loop = loop; closeall = closeall; |