fix
This commit is contained in:
parent
21f8edda02
commit
df0857142c
@ -2,7 +2,7 @@
|
||||
%%% @author anlicheng
|
||||
%%% @copyright (C) 2025, <COMPANY>
|
||||
%%% @doc
|
||||
%%%
|
||||
%%% 负责和云端服务器的通讯
|
||||
%%% @end
|
||||
%%% Created : 29. 4月 2025 17:47
|
||||
%%%-------------------------------------------------------------------
|
||||
@ -98,29 +98,23 @@ handle_event(info, {connect_reply, Reply}, ?STATE_CONNECTING, State = #state{tra
|
||||
end;
|
||||
|
||||
%% 权限校验的回复
|
||||
handle_event(info, {auth_reply, Reply}, ?STATE_AUTH, State = #state{transport_pid = TransportPid}) ->
|
||||
case Reply of
|
||||
{ok, #auth_reply{code = 1, message = Message, repository_url = RepositoryUrl}} ->
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
|
||||
{next_state, ?STATE_ACTIVATED, State};
|
||||
|
||||
%% 主机在后台的授权未通过;此时agent不能推送数据给云端服务器,但是云端服务器可以推送命令给agent
|
||||
%% socket的连接状态需要维持
|
||||
{ok, #auth_reply{code = -1, message = Message}} ->
|
||||
efka_logger:debug("[efka_agent] auth denied, message: ~p", [Message]),
|
||||
{next_state, ?STATE_RESTRICTED, State};
|
||||
|
||||
%% 其他类型的错误,需要间隔时间重试
|
||||
{ok, #auth_reply{code = -2, message = Message}} ->
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{next_state, ?STATE_DENIED, State#state{transport_pid = undefined}};
|
||||
|
||||
{error, Reason} ->
|
||||
efka_logger:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{next_state, ?STATE_DENIED, State#state{transport_pid = undefined}}
|
||||
end;
|
||||
handle_event(info, {auth_reply, {ok, #auth_reply{code = 1, message = Message, repository_url = RepositoryUrl}}}, ?STATE_AUTH, State = #state{transport_pid = TransportPid}) ->
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
|
||||
{next_state, ?STATE_ACTIVATED, State};
|
||||
handle_event(info, {auth_reply, {ok, #auth_reply{code = -1, message = Message}}}, ?STATE_AUTH, State = #state{transport_pid = TransportPid}) ->
|
||||
%% 主机在后台的授权未通过;此时agent不能推送数据给云端服务器,但是云端服务器可以推送命令给agent
|
||||
%% socket的连接状态需要维持
|
||||
efka_logger:debug("[efka_agent] auth denied, message: ~p", [Message]),
|
||||
{next_state, ?STATE_RESTRICTED, State};
|
||||
handle_event(info, {auth_reply, {ok, #auth_reply{code = -2, message = Message}}}, ?STATE_AUTH, State = #state{transport_pid = TransportPid}) ->
|
||||
%% 其他类型的错误,需要间隔时间重试
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{next_state, ?STATE_DENIED, State#state{transport_pid = undefined}};
|
||||
handle_event(info, {auth_reply, {error, Reason}}, ?STATE_AUTH, State = #state{transport_pid = TransportPid}) ->
|
||||
efka_logger:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{next_state, ?STATE_DENIED, State#state{transport_pid = undefined}};
|
||||
|
||||
%% 云端服务器推送了消息
|
||||
%% 激活消息
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
%%% @author anlicheng
|
||||
%%% @copyright (C) 2025, <COMPANY>
|
||||
%%% @doc
|
||||
%%%
|
||||
%%% 用于管理manifest.json配置文件
|
||||
%%% @end
|
||||
%%% Created : 05. 5月 2025 22:39
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
@ -97,7 +97,7 @@ handle_cast(connect, State = #state{host = Host, port = Port, parent_pid = Paren
|
||||
],
|
||||
case ssl:connect(Host, Port, SslOptions, 5000) of
|
||||
{ok, Socket} ->
|
||||
ssl:controlling_process(Socket, self()),
|
||||
ok = ssl:controlling_process(Socket, self()),
|
||||
ParentPid ! {connect_reply, ok},
|
||||
{noreply, State#state{socket = Socket}};
|
||||
{error, Reason} ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user