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 %%% @author anlicheng
%%% @copyright (C) 2025, <COMPANY> %%% @copyright (C) 2025, <COMPANY>
%%% @doc %%% @doc
%%% %%%
%%% @end %%% @end
%%% Created : 29. 4 2025 17:47 %%% Created : 29. 4 2025 17:47
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
@ -98,29 +98,23 @@ handle_event(info, {connect_reply, Reply}, ?STATE_CONNECTING, State = #state{tra
end; end;
%% %%
handle_event(info, {auth_reply, Reply}, ?STATE_AUTH, State = #state{transport_pid = TransportPid}) -> handle_event(info, {auth_reply, {ok, #auth_reply{code = 1, message = Message, repository_url = RepositoryUrl}}}, ?STATE_AUTH, State = #state{transport_pid = TransportPid}) ->
case Reply of efka_logger:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
{ok, #auth_reply{code = 1, message = Message, repository_url = RepositoryUrl}} -> {next_state, ?STATE_ACTIVATED, State};
efka_logger:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]), handle_event(info, {auth_reply, {ok, #auth_reply{code = -1, message = Message}}}, ?STATE_AUTH, State = #state{transport_pid = TransportPid}) ->
{next_state, ?STATE_ACTIVATED, State}; %% agent不能推送数据给云端服务器agent
%% socket的连接状态需要维持
%% agent不能推送数据给云端服务器agent efka_logger:debug("[efka_agent] auth denied, message: ~p", [Message]),
%% socket的连接状态需要维持 {next_state, ?STATE_RESTRICTED, State};
{ok, #auth_reply{code = -1, message = Message}} -> 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 denied, message: ~p", [Message]), %%
{next_state, ?STATE_RESTRICTED, State}; efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]),
efka_transport:stop(TransportPid),
%% {next_state, ?STATE_DENIED, State#state{transport_pid = undefined}};
{ok, #auth_reply{code = -2, message = Message}} -> handle_event(info, {auth_reply, {error, Reason}}, ?STATE_AUTH, State = #state{transport_pid = TransportPid}) ->
efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]), efka_logger:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
efka_transport:stop(TransportPid), efka_transport:stop(TransportPid),
{next_state, ?STATE_DENIED, State#state{transport_pid = undefined}}; {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;
%% %%
%% %%

View File

@ -2,7 +2,7 @@
%%% @author anlicheng %%% @author anlicheng
%%% @copyright (C) 2025, <COMPANY> %%% @copyright (C) 2025, <COMPANY>
%%% @doc %%% @doc
%%% %%% manifest.json配置文件
%%% @end %%% @end
%%% Created : 05. 5 2025 22:39 %%% 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 case ssl:connect(Host, Port, SslOptions, 5000) of
{ok, Socket} -> {ok, Socket} ->
ssl:controlling_process(Socket, self()), ok = ssl:controlling_process(Socket, self()),
ParentPid ! {connect_reply, ok}, ParentPid ! {connect_reply, ok},
{noreply, State#state{socket = Socket}}; {noreply, State#state{socket = Socket}};
{error, Reason} -> {error, Reason} ->