This commit is contained in:
anlicheng 2025-05-05 23:43:57 +08:00
parent 21f8edda02
commit df0857142c
3 changed files with 20 additions and 26 deletions

View File

@ -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}};
%%
%%

View File

@ -2,7 +2,7 @@
%%% @author anlicheng
%%% @copyright (C) 2025, <COMPANY>
%%% @doc
%%%
%%% manifest.json配置文件
%%% @end
%%% Created : 05. 5 2025 22:39
%%%-------------------------------------------------------------------

View File

@ -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} ->