fix
This commit is contained in:
parent
3f5a13aa65
commit
a2af6feaca
@ -106,25 +106,27 @@ handle_info({connect_reply, Reply}, State = #state{status = ?STATE_CONNECTING, t
|
||||
{noreply, ?STATE_DENIED, State#state{status = ?STATE_DENIED}}
|
||||
end;
|
||||
|
||||
handle_info({auth_reply, {ok, #auth_reply{code = 1, message = Message, repository_url = RepositoryUrl}}}, State = #state{status = ?STATE_AUTH}) ->
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
|
||||
{noreply, State#state{status = ?STATE_ACTIVATED}};
|
||||
handle_info({auth_reply, {ok, #auth_reply{code = -1, message = Message}}}, State = #state{status = ?STATE_AUTH}) ->
|
||||
%% 主机在后台的授权未通过;此时agent不能推送数据给云端服务器,但是云端服务器可以推送命令给agent
|
||||
%% socket的连接状态需要维持
|
||||
efka_logger:debug("[efka_agent] auth denied, message: ~p", [Message]),
|
||||
{noreply, State#state{status = ?STATE_RESTRICTED}};
|
||||
handle_info({auth_reply, {ok, #auth_reply{code = -2, message = Message}}}, State = #state{transport_pid = TransportPid, status = ?STATE_AUTH}) ->
|
||||
%% 其他类型的错误,需要间隔时间重试
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
|
||||
handle_info({auth_reply, {ok, ReplyBin}}, State = #state{status = ?STATE_AUTH, transport_pid = TransportPid}) ->
|
||||
case 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]),
|
||||
{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]),
|
||||
{noreply, State#state{status = ?STATE_RESTRICTED}};
|
||||
#auth_reply{code = -2, message = Message} ->
|
||||
% 其他类型的错误,需要间隔时间重试
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]),
|
||||
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]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
|
||||
|
||||
|
||||
%% 云端服务器推送了消息
|
||||
%% 激活消息
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ handle_cast({auth_request, Timeout}, State = #state{parent_pid = ParentPid, sock
|
||||
%% 需要等待auth返回的结果
|
||||
receive
|
||||
{ssl, Socket, <<?PACKET_RESPONSE, PacketId:32, ?METHOD_AUTH, ReplyBin/binary>>} ->
|
||||
ParentPid ! {auth_reply, {ok, message_pb:decode_msg(ReplyBin, auth_reply)}},
|
||||
ParentPid ! {auth_reply, {ok, ReplyBin}},
|
||||
{noreply, State#state{packet_id = PacketId + 1}}
|
||||
after Timeout ->
|
||||
ParentPid ! {auth_reply, {error, timeout}},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user