This commit is contained in:
anlicheng 2025-05-06 10:00:10 +08:00
parent a2af6feaca
commit 4e73d2a588

View File

@ -107,23 +107,33 @@ handle_info({connect_reply, Reply}, State = #state{status = ?STATE_CONNECTING, t
end;
handle_info({auth_reply, {ok, ReplyBin}}, State = #state{status = ?STATE_AUTH, transport_pid = TransportPid}) ->
case message_pb:decode_msg(ReplyBin, auth_reply) of
try message_pb:decode_msg(ReplyBin, auth_reply) of
#auth_reply{code = 1, message = Message, repository_url = RepositoryUrl} ->
efka_logger:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
lager:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
{noreply, State#state{status = ?STATE_ACTIVATED}};
%% agent不能推送数据给云端服务器agent
%% socket的连接状态需要维持
#auth_reply{code = -1, message = Message} ->
efka_logger:debug("[efka_agent] auth denied, message: ~p", [Message]),
#auth_reply{code = -1, message = Message, repository_url = _} ->
lager:debug("[efka_agent] auth denied, message: ~p", [Message]),
{noreply, State#state{status = ?STATE_RESTRICTED}};
#auth_reply{code = -2, message = Message} ->
#auth_reply{code = -2, message = Message, repository_url = _} ->
%
efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]),
efka_transport:stop(TransportPid),
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
_ ->
%
lager:debug("[efka_agent] auth failed, invalid message"),
efka_transport:stop(TransportPid),
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}
catch _:Reason ->
%
lager:debug("[efka_agent] auth decode bin get error: ~p", [Reason]),
efka_transport:stop(TransportPid),
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}
end;
handle_info({auth_reply, {error, Reason}}, State = #state{transport_pid = TransportPid, status = ?STATE_AUTH}) ->
efka_logger:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
lager:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
efka_transport:stop(TransportPid),
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};