mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
https set extension:server_name (#1960)
Co-authored-by: root <root@DESKTOP-5DF4NN3.localdomain>
This commit is contained in:
@@ -267,6 +267,15 @@ _ltls_context_write(lua_State* L) {
|
|||||||
return 1;
|
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
|
static int
|
||||||
_lctx_gc(lua_State* L) {
|
_lctx_gc(lua_State* L) {
|
||||||
@@ -378,6 +387,7 @@ lnew_tls(lua_State* L) {
|
|||||||
{"handshake", _ltls_context_handshake},
|
{"handshake", _ltls_context_handshake},
|
||||||
{"read", _ltls_context_read},
|
{"read", _ltls_context_read},
|
||||||
{"write", _ltls_context_write},
|
{"write", _ltls_context_write},
|
||||||
|
{"set_ext_host_name", _lset_ext_host_name},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
luaL_newlib(L, l);
|
luaL_newlib(L, l);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ local function connect(host, timeout)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
if interface.init then
|
if interface.init then
|
||||||
interface.init()
|
interface.init((header and header.Host) or host)
|
||||||
end
|
end
|
||||||
return fd, interface, host
|
return fd, interface, host
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ local tlshelper = {}
|
|||||||
function tlshelper.init_requestfunc(fd, tls_ctx)
|
function tlshelper.init_requestfunc(fd, tls_ctx)
|
||||||
local readfunc = socket.readfunc(fd)
|
local readfunc = socket.readfunc(fd)
|
||||||
local writefunc = socket.writefunc(fd)
|
local writefunc = socket.writefunc(fd)
|
||||||
return function ()
|
return function (hostname)
|
||||||
|
tls_ctx:set_ext_host_name(hostname)
|
||||||
local ds1 = tls_ctx:handshake()
|
local ds1 = tls_ctx:handshake()
|
||||||
writefunc(ds1)
|
writefunc(ds1)
|
||||||
while not tls_ctx:finished() do
|
while not tls_ctx:finished() do
|
||||||
|
|||||||
Reference in New Issue
Block a user