Software /
code /
prosody
Changeset
9497:183ff7a8051b
net.server_epoll: Add support for the conn_type argument to addclient
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 12 Oct 2018 16:26:19 +0200 |
parents | 9496:4ac3103787cc |
children | 9498:cc593002f2e2 |
files | net/server_epoll.lua |
diffstat | 1 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_epoll.lua Fri Oct 12 16:25:30 2018 +0200 +++ b/net/server_epoll.lua Fri Oct 12 16:26:19 2018 +0200 @@ -625,14 +625,22 @@ end -- New outgoing TCP connection -local function addclient(addr, port, listeners, read_size, tls_ctx) - local n = inet_pton(addr); - if not n then return nil, "invalid-ip"; end - local create - if #n == 16 then - create = socket.tcp6 or socket.tcp; - else - create = socket.tcp4 or socket.tcp; +local function addclient(addr, port, listeners, read_size, tls_ctx, typ) + local create; + if not typ then + local n = inet_pton(addr); + if not n then return nil, "invalid-ip"; end + if #n == 16 then + typ = "tcp6"; + else + typ = "tcp4"; + end + end + if typ then + create = socket[typ]; + end + if type(create) ~= "function" then + return nil, "invalid socket type"; end local conn, err = create(); conn:settimeout(0);