fix(gw_jt808): make static check happy

This commit is contained in:
JimMoen 2023-12-14 14:51:01 +08:00
parent d1adcd464e
commit 944bb596c0
No known key found for this signature in database
GPG Key ID: 87A520B4F76BA86D
1 changed files with 14 additions and 11 deletions

View File

@ -255,21 +255,27 @@ do_handle_in(Frame = ?MSG(?MC_REGISTER), Channel0) ->
end, end,
handle_out({?MS_REGISTER_ACK, ResCode}, MsgSn, Channel0) handle_out({?MS_REGISTER_ACK, ResCode}, MsgSn, Channel0)
end; end;
do_handle_in(Frame = ?MSG(?MC_AUTH), Channel) -> do_handle_in(Frame = ?MSG(?MC_AUTH), Channel0) ->
#{<<"header">> := #{<<"msg_sn">> := MsgSn}} = Frame,
case case
emqx_utils:pipeline( emqx_utils:pipeline(
[ [
fun enrich_clientinfo/2, fun enrich_clientinfo/2,
fun enrich_conninfo/2, fun enrich_conninfo/2,
fun set_log_meta/2, fun set_log_meta/2
fun auth_connect/2
], ],
Frame, Frame,
Channel Channel0
) )
of of
{ok, _NFrame, NChannel} -> {ok, _NFrame, Channel} ->
_ = process_connect(Frame, ensure_connected(NChannel)) case authenticate(Frame, Channel) of
true ->
NChannel = process_connect(Frame, ensure_connected(Channel)),
authack({0, MsgSn, NChannel});
false ->
authack({1, MsgSn, Channel})
end
end; end;
do_handle_in(Frame = ?MSG(?MC_HEARTBEAT), Channel) -> do_handle_in(Frame = ?MSG(?MC_HEARTBEAT), Channel) ->
handle_out({?MS_GENERAL_RESPONSE, 0, ?MC_HEARTBEAT}, msgsn(Frame), Channel); handle_out({?MS_GENERAL_RESPONSE, 0, ?MC_HEARTBEAT}, msgsn(Frame), Channel);
@ -630,7 +636,7 @@ maybe_fix_mountpoint(ClientInfo = #{mountpoint := Mountpoint}) ->
ClientInfo#{mountpoint := Mountpoint1}. ClientInfo#{mountpoint := Mountpoint1}.
process_connect( process_connect(
_Frame = #{<<"header">> := #{<<"msg_sn">> := MsgSn}}, _Frame,
Channel = #channel{ Channel = #channel{
ctx = Ctx, ctx = Ctx,
conninfo = ConnInfo, conninfo = ConnInfo,
@ -656,7 +662,7 @@ process_connect(
_ = emqx_gateway_ctx:insert_channel_info( _ = emqx_gateway_ctx:insert_channel_info(
Ctx, ClientId, info(NChannel), stats(NChannel) Ctx, ClientId, info(NChannel), stats(NChannel)
), ),
authack({0, MsgSn, NChannel}); NChannel;
{error, Reason} -> {error, Reason} ->
log( log(
error, error,
@ -853,9 +859,6 @@ is_driver_id_req_exist(#channel{inflight = Inflight}) ->
Key = get_msg_ack(?MC_DRIVER_ID_REPORT, none), Key = get_msg_ack(?MC_DRIVER_ID_REPORT, none),
emqx_inflight:contain(Key, Inflight). emqx_inflight:contain(Key, Inflight).
auth_connect(Frame, Channel) ->
{ok, Channel#channel{auth = authenticate(Frame, Channel)}}.
authenticate(_AuthFrame, #channel{authcode = anonymous}) -> authenticate(_AuthFrame, #channel{authcode = anonymous}) ->
true; true;
authenticate(AuthFrame, #channel{authcode = undefined, auth = Auth}) -> authenticate(AuthFrame, #channel{authcode = undefined, auth = Auth}) ->