fix
This commit is contained in:
parent
6d6a9c4585
commit
87874135aa
@ -134,10 +134,8 @@ handle_event(info, {timeout, _, create_transport}, ?STATE_DISCONNECTED, State =
|
|||||||
Ref = make_ref(),
|
Ref = make_ref(),
|
||||||
AuthPacket = auth_packet(Ref),
|
AuthPacket = auth_packet(Ref),
|
||||||
ok = ssl:send(Socket, AuthPacket),
|
ok = ssl:send(Socket, AuthPacket),
|
||||||
{next_state, ?STATE_AUTH, State#state{socket = Socket, auth_ref = Ref},
|
{next_state, ?STATE_AUTH, State#state{socket = Socket, auth_ref = Ref}, [{state_timeout, 5000, auth_timeout}]};
|
||||||
[{state_timeout, 5000, auth_timeout}]};
|
|
||||||
{error, _Reason} ->
|
{error, _Reason} ->
|
||||||
%logger:debug("[efka_client] connect failed"),
|
|
||||||
schedule_reconnect(),
|
schedule_reconnect(),
|
||||||
{keep_state, State#state{socket = undefined}}
|
{keep_state, State#state{socket = undefined}}
|
||||||
end;
|
end;
|
||||||
@ -222,16 +220,13 @@ handle_event(internal, {request, Ref, {container_request, Request}}, _StateName,
|
|||||||
{keep_state, State};
|
{keep_state, State};
|
||||||
|
|
||||||
%% 处理response
|
%% 处理response
|
||||||
handle_event(internal, {response, AuthRef, {auth_response, ok}},
|
handle_event(internal, {response, AuthRef, {auth_response, ok}}, ?STATE_AUTH, State = #state{auth_ref = AuthRef}) ->
|
||||||
?STATE_AUTH, State = #state{auth_ref = AuthRef}) ->
|
|
||||||
logger:debug("[efka_client] auth success"),
|
logger:debug("[efka_client] auth success"),
|
||||||
{next_state, ?STATE_ACTIVATED, State#state{auth_ref = undefined}, [{next_event, info, flush_cache}]};
|
{next_state, ?STATE_ACTIVATED, State#state{auth_ref = undefined}, [{next_event, info, flush_cache}]};
|
||||||
handle_event(internal, {response, AuthRef, {auth_response, {error, {denied, Message}}}},
|
handle_event(internal, {response, AuthRef, {auth_response, {error, {denied, Message}}}}, ?STATE_AUTH, State = #state{auth_ref = AuthRef}) ->
|
||||||
?STATE_AUTH, State = #state{auth_ref = AuthRef}) ->
|
|
||||||
logger:debug("[efka_client] auth denied, message: ~p", [Message]),
|
logger:debug("[efka_client] auth denied, message: ~p", [Message]),
|
||||||
{next_state, ?STATE_RESTRICTED, State#state{auth_ref = undefined}};
|
{next_state, ?STATE_RESTRICTED, State#state{auth_ref = undefined}};
|
||||||
handle_event(internal, {response, AuthRef, {auth_response, {error, Reason}}},
|
handle_event(internal, {response, AuthRef, {auth_response, {error, Reason}}}, ?STATE_AUTH, State = #state{socket = Socket, auth_ref = AuthRef}) ->
|
||||||
?STATE_AUTH, State = #state{socket = Socket, auth_ref = AuthRef}) ->
|
|
||||||
logger:debug("[efka_client] auth failed, reason: ~p", [Reason]),
|
logger:debug("[efka_client] auth failed, reason: ~p", [Reason]),
|
||||||
disconnect(Socket),
|
disconnect(Socket),
|
||||||
schedule_reconnect(),
|
schedule_reconnect(),
|
||||||
@ -241,9 +236,7 @@ handle_event(internal, {response, _Ref, Reply}, StateName, State) ->
|
|||||||
{keep_state, State};
|
{keep_state, State};
|
||||||
|
|
||||||
%% 处理命令
|
%% 处理命令
|
||||||
handle_event(internal, {message, {auth_control, Cmd}},
|
handle_event(internal, {message, {auth_control, Cmd}}, StateName, State = #state{socket = Socket}) ->
|
||||||
StateName, State = #state{socket = Socket}) ->
|
|
||||||
|
|
||||||
logger:debug("[efka_client] auth cmd: ~p", [Cmd]),
|
logger:debug("[efka_client] auth cmd: ~p", [Cmd]),
|
||||||
case {Cmd, StateName} of
|
case {Cmd, StateName} of
|
||||||
{activate, ?STATE_ACTIVATED} ->
|
{activate, ?STATE_ACTIVATED} ->
|
||||||
@ -252,8 +245,7 @@ handle_event(internal, {message, {auth_control, Cmd}},
|
|||||||
Ref = make_ref(),
|
Ref = make_ref(),
|
||||||
AuthPacket = auth_packet(Ref),
|
AuthPacket = auth_packet(Ref),
|
||||||
ok = ssl:send(Socket, AuthPacket),
|
ok = ssl:send(Socket, AuthPacket),
|
||||||
{next_state, ?STATE_AUTH, State#state{auth_ref = Ref},
|
{next_state, ?STATE_AUTH, State#state{auth_ref = Ref}, [{state_timeout, 5000, auth_timeout}]};
|
||||||
[{state_timeout, 5000, auth_timeout}]};
|
|
||||||
{deactivate, _} ->
|
{deactivate, _} ->
|
||||||
{next_state, ?STATE_RESTRICTED, State}
|
{next_state, ?STATE_RESTRICTED, State}
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user