fix
This commit is contained in:
parent
8d89223f3c
commit
5a795fc142
@ -19,10 +19,14 @@
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
|
||||
|
||||
-define(SERVER, ?MODULE).
|
||||
-define(SERVER, ?MODULE).
|
||||
|
||||
-define(STATE_DENIED, denied).
|
||||
-define(STATE_ACTIVATED, activated).
|
||||
|
||||
-record(state, {
|
||||
transport_pid :: undefined | pid()
|
||||
transport_pid :: undefined | pid(),
|
||||
status = ?STATE_DENIED
|
||||
}).
|
||||
|
||||
%%%===================================================================
|
||||
@ -82,22 +86,22 @@ handle_info({timeout, _, create_transport}, State = #state{}) ->
|
||||
%% 验证通过
|
||||
{ok, #auth_reply{code = 1, message = Message, repository_url = RepositoryUrl}} ->
|
||||
lager:debug("[efka_agent] auth result: ~p, repository_url: ~p", [Message, RepositoryUrl]),
|
||||
{noreply, State#state{transport_pid = TransportPid}};
|
||||
{noreply, State#state{transport_pid = TransportPid, status = ?STATE_ACTIVATED}};
|
||||
|
||||
%% 主机denied状态
|
||||
{ok, #auth_reply{code = -1, message = Message, repository_url = RepositoryUrl}} ->
|
||||
lager:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
|
||||
{noreply, State#state{transport_pid = TransportPid}};
|
||||
{noreply, State#state{transport_pid = TransportPid, status = ?STATE_DENIED}};
|
||||
|
||||
%% 验证不通过
|
||||
{ok, #auth_reply{code = -2, message = Message, repository_url = RepositoryUrl}} ->
|
||||
lager:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
|
||||
{noreply, State#state{transport_pid = undefined}};
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
|
||||
|
||||
{error, Reason} ->
|
||||
lager:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{noreply, State#state{transport_pid = undefined}}
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}
|
||||
end;
|
||||
|
||||
handle_info({'EXIT', _Pid, Reason}, State = #state{}) ->
|
||||
|
||||
@ -106,7 +106,6 @@ handle_call({auth_request, Timeout}, _From, State = #state{socket = Socket, pack
|
||||
%% 需要等待auth返回的结果
|
||||
receive
|
||||
{ssl, Socket, <<?PACKET_RESPONSE, PacketId:32, ?METHOD_AUTH, ReplyBin/binary>>} ->
|
||||
lager:debug("[efka_agent] get a reply bin: ~p", [ReplyBin]),
|
||||
{reply, {ok, message_pb:decode_msg(ReplyBin, auth_reply)}, State#state{packet_id = PacketId + 1}}
|
||||
after
|
||||
Timeout ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user