https set extension:server_name (#1960)

Co-authored-by: root <root@DESKTOP-5DF4NN3.localdomain>
This commit is contained in:
2024-07-24 11:55:05 +08:00
committed by GitHub
parent b519c53fe4
commit 89372a257d
3 changed files with 13 additions and 2 deletions

View File

@@ -267,6 +267,15 @@ _ltls_context_write(lua_State* L) {
return 1;
}
static int
_lset_ext_host_name(lua_State* L) {
struct tls_context* tls_p = _check_context(L, 1);
size_t slen = 0;
char* host = (char*)lua_tolstring(L, 2, &slen);
int ret = SSL_set_tlsext_host_name(tls_p->ssl, host);
lua_pushinteger(L, ret);
return 1;
}
static int
_lctx_gc(lua_State* L) {
@@ -378,6 +387,7 @@ lnew_tls(lua_State* L) {
{"handshake", _ltls_context_handshake},
{"read", _ltls_context_read},
{"write", _ltls_context_write},
{"set_ext_host_name", _lset_ext_host_name},
{NULL, NULL},
};
luaL_newlib(L, l);

View File

@@ -95,7 +95,7 @@ local function connect(host, timeout)
end)
end
if interface.init then
interface.init()
interface.init((header and header.Host) or host)
end
return fd, interface, host
end

View File

@@ -6,7 +6,8 @@ local tlshelper = {}
function tlshelper.init_requestfunc(fd, tls_ctx)
local readfunc = socket.readfunc(fd)
local writefunc = socket.writefunc(fd)
return function ()
return function (hostname)
tls_ctx:set_ext_host_name(hostname)
local ds1 = tls_ctx:handshake()
writefunc(ds1)
while not tls_ctx:finished() do