Merge pull request #7824 from HJianBo/fix-gw-http-body
fix(gw): fix deep_merge can't update the configuration correctly
This commit is contained in:
commit
7a8a1f8b6a
|
@ -493,12 +493,9 @@ pre_config_update(_, {update_authn, GwName, Conf}, RawConf) ->
|
||||||
of
|
of
|
||||||
undefined ->
|
undefined ->
|
||||||
badres_authn(not_found, GwName);
|
badres_authn(not_found, GwName);
|
||||||
_ ->
|
Authn ->
|
||||||
{ok,
|
NAuthn = maps:merge(Authn, Conf),
|
||||||
emqx_map_lib:deep_merge(
|
{ok, emqx_map_lib:deep_put([GwName, ?AUTHN_BIN], RawConf, NAuthn)}
|
||||||
RawConf,
|
|
||||||
#{GwName => #{?AUTHN_BIN => Conf}}
|
|
||||||
)}
|
|
||||||
end;
|
end;
|
||||||
pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) ->
|
pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) ->
|
||||||
case
|
case
|
||||||
|
@ -517,17 +514,15 @@ pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) ->
|
||||||
Auth ->
|
Auth ->
|
||||||
NListener = maps:put(
|
NListener = maps:put(
|
||||||
?AUTHN_BIN,
|
?AUTHN_BIN,
|
||||||
emqx_map_lib:deep_merge(Auth, Conf),
|
maps:merge(Auth, Conf),
|
||||||
Listener
|
Listener
|
||||||
),
|
),
|
||||||
NGateway = #{
|
{ok,
|
||||||
GwName =>
|
emqx_map_lib:deep_put(
|
||||||
#{
|
[GwName, <<"listeners">>, LType, LName],
|
||||||
<<"listeners">> =>
|
RawConf,
|
||||||
#{LType => #{LName => NListener}}
|
NListener
|
||||||
}
|
)}
|
||||||
},
|
|
||||||
{ok, emqx_map_lib:deep_merge(RawConf, NGateway)}
|
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
pre_config_update(_, {remove_authn, GwName}, RawConf) ->
|
pre_config_update(_, {remove_authn, GwName}, RawConf) ->
|
||||||
|
|
|
@ -344,7 +344,7 @@ ensure_connected(
|
||||||
clientinfo = ClientInfo
|
clientinfo = ClientInfo
|
||||||
}
|
}
|
||||||
) ->
|
) ->
|
||||||
_ = run_hooks(Ctx, 'client.connack', [ConnInfo, connection_accepted, []]),
|
_ = run_hooks(Ctx, 'client.connack', [ConnInfo, connection_accepted, #{}]),
|
||||||
|
|
||||||
NConnInfo = ConnInfo#{connected_at => erlang:system_time(millisecond)},
|
NConnInfo = ConnInfo#{connected_at => erlang:system_time(millisecond)},
|
||||||
ok = run_hooks(Ctx, 'client.connected', [ClientInfo, NConnInfo]),
|
ok = run_hooks(Ctx, 'client.connected', [ClientInfo, NConnInfo]),
|
||||||
|
|
|
@ -262,6 +262,17 @@ enrich_clientinfo(
|
||||||
),
|
),
|
||||||
{ok, NPacket, Channel#channel{clientinfo = NClientInfo}}.
|
{ok, NPacket, Channel#channel{clientinfo = NClientInfo}}.
|
||||||
|
|
||||||
|
assign_clientid_to_conninfo(
|
||||||
|
Packet,
|
||||||
|
Channel = #channel{
|
||||||
|
conninfo = ConnInfo,
|
||||||
|
clientinfo = ClientInfo
|
||||||
|
}
|
||||||
|
) ->
|
||||||
|
ClientId = maps:get(clientid, ClientInfo),
|
||||||
|
NConnInfo = maps:put(clientid, ClientId, ConnInfo),
|
||||||
|
{ok, Packet, Channel#channel{conninfo = NConnInfo}}.
|
||||||
|
|
||||||
feedvar(Override, Packet, ConnInfo, ClientInfo) ->
|
feedvar(Override, Packet, ConnInfo, ClientInfo) ->
|
||||||
Envs = #{
|
Envs = #{
|
||||||
'ConnInfo' => ConnInfo,
|
'ConnInfo' => ConnInfo,
|
||||||
|
@ -409,6 +420,7 @@ handle_in(Packet = ?PACKET(?CMD_CONNECT), Channel) ->
|
||||||
fun run_conn_hooks/2,
|
fun run_conn_hooks/2,
|
||||||
fun negotiate_version/2,
|
fun negotiate_version/2,
|
||||||
fun enrich_clientinfo/2,
|
fun enrich_clientinfo/2,
|
||||||
|
fun assign_clientid_to_conninfo/2,
|
||||||
fun set_log_meta/2,
|
fun set_log_meta/2,
|
||||||
%% TODO: How to implement the banned in the gateway instance?
|
%% TODO: How to implement the banned in the gateway instance?
|
||||||
%, fun check_banned/2
|
%, fun check_banned/2
|
||||||
|
|
Loading…
Reference in New Issue