From 61dd9fbc74ceb1399473a82d0397e9ad2326703b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 1 Sep 2019 01:58:38 +0200 Subject: net.server: Handle server name (SNI) as extra argument Code added in 75d2874502c3, 9a905888b96c and adc0672b700e uses this field. See #409 and #1408 --- net/server_epoll.lua | 6 ++++++ net/server_event.lua | 1 + net/server_select.lua | 3 +++ 3 files changed, 10 insertions(+) diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 96e7b201..f48086e3 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -575,6 +575,12 @@ local function wrapsocket(client, server, read_size, listeners, tls_ctx, extra) extra = extra; }, interface_mt); + if extra then + if extra.servername then + conn.servername = extra.servername; + end + end + conn:updatenames(); return conn; end diff --git a/net/server_event.lua b/net/server_event.lua index 950a7a5c..2b791291 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -516,6 +516,7 @@ local function handleclient( client, ip, port, server, pattern, listener, sslctx _sslctx = sslctx; -- parameters _usingssl = false; -- client is using ssl; extra = extra; + servername = extra and extra.servername; } if not has_luasec then interface.starttls = false; end interface.id = tostring(interface):match("%x+$"); diff --git a/net/server_select.lua b/net/server_select.lua index de183331..e15f5298 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -317,6 +317,9 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport local handler = bufferqueue -- saves a table ^_^ handler.extra = extra + if extra then + handler.servername = extra.servername + end handler.dispatch = function( ) return dispatch -- cgit v1.2.3