fix(chan): postpone trimming conninfo until `connected` hooks run
Some users expect to get the peer certificate in `connected` hooks, but the `conninfo` was trimmed before `connected` hooks run.
This commit is contained in:
parent
6813ea8e7a
commit
b341a04955
|
@ -256,9 +256,7 @@ init(
|
||||||
),
|
),
|
||||||
{NClientInfo, NConnInfo} = take_ws_cookie(ClientInfo, ConnInfo),
|
{NClientInfo, NConnInfo} = take_ws_cookie(ClientInfo, ConnInfo),
|
||||||
#channel{
|
#channel{
|
||||||
%% We remove the peercert because it duplicates to what's stored in the socket,
|
conninfo = NConnInfo,
|
||||||
%% Saving a copy here causes unnecessary wast of memory (about 1KB per connection).
|
|
||||||
conninfo = maps:put(peercert, undefined, NConnInfo),
|
|
||||||
clientinfo = NClientInfo,
|
clientinfo = NClientInfo,
|
||||||
topic_aliases = #{
|
topic_aliases = #{
|
||||||
inbound => #{},
|
inbound => #{},
|
||||||
|
@ -1989,10 +1987,21 @@ ensure_connected(
|
||||||
NConnInfo = ConnInfo#{connected_at => erlang:system_time(millisecond)},
|
NConnInfo = ConnInfo#{connected_at => erlang:system_time(millisecond)},
|
||||||
ok = run_hooks('client.connected', [ClientInfo, NConnInfo]),
|
ok = run_hooks('client.connected', [ClientInfo, NConnInfo]),
|
||||||
Channel#channel{
|
Channel#channel{
|
||||||
conninfo = NConnInfo,
|
conninfo = trim_conninfo(NConnInfo),
|
||||||
conn_state = connected
|
conn_state = connected
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
trim_conninfo(ConnInfo) ->
|
||||||
|
maps:without(
|
||||||
|
[
|
||||||
|
%% NOTE
|
||||||
|
%% We remove the peercert because it duplicates what's stored in the socket,
|
||||||
|
%% otherwise it wastes about 1KB per connection.
|
||||||
|
peercert
|
||||||
|
],
|
||||||
|
ConnInfo
|
||||||
|
).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Init Alias Maximum
|
%% Init Alias Maximum
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
socktype := socktype(),
|
socktype := socktype(),
|
||||||
sockname := peername(),
|
sockname := peername(),
|
||||||
peername := peername(),
|
peername := peername(),
|
||||||
peercert := nossl | undefined | esockd_peercert:peercert(),
|
peercert => nossl | undefined | esockd_peercert:peercert(),
|
||||||
conn_mod := module(),
|
conn_mod := module(),
|
||||||
proto_name => binary(),
|
proto_name => binary(),
|
||||||
proto_ver => proto_ver(),
|
proto_ver => proto_ver(),
|
||||||
|
|
Loading…
Reference in New Issue