mirror of
https://github.com/internetee/epp_proxy.git
synced 2025-08-21 06:44:21 +02:00
Reformat code
This commit is contained in:
parent
e867e15ce7
commit
f17613b5f7
1 changed files with 12 additions and 11 deletions
|
@ -98,9 +98,9 @@ handle_cast(process_command,
|
||||||
%% Else, go back to the beginning of the loop.
|
%% Else, go back to the beginning of the loop.
|
||||||
if Command =:= "logout" ->
|
if Command =:= "logout" ->
|
||||||
case gen_tcp:shutdown(Socket, read_write) of
|
case gen_tcp:shutdown(Socket, read_write) of
|
||||||
ok -> {stop, normal, State};
|
ok -> {stop, normal, State};
|
||||||
{error, closed} -> {stop, normal, State}
|
{error, closed} -> {stop, normal, State}
|
||||||
end;
|
end;
|
||||||
true ->
|
true ->
|
||||||
gen_server:cast(self(), process_command),
|
gen_server:cast(self(), process_command),
|
||||||
{noreply,
|
{noreply,
|
||||||
|
@ -135,13 +135,13 @@ state_from_socket(Socket, State) ->
|
||||||
|
|
||||||
frame_from_socket(Socket, State) ->
|
frame_from_socket(Socket, State) ->
|
||||||
case gen_tcp:recv(Socket, 0, ?DefaultTimeout) of
|
case gen_tcp:recv(Socket, 0, ?DefaultTimeout) of
|
||||||
{ok, Data} ->
|
{ok, Data} ->
|
||||||
EPPEnvelope = binary:part(Data, {0, 4}),
|
EPPEnvelope = binary:part(Data, {0, 4}),
|
||||||
ReportedLength = binary:decode_unsigned(EPPEnvelope,
|
ReportedLength = binary:decode_unsigned(EPPEnvelope,
|
||||||
big),
|
big),
|
||||||
read_until_exhausted(Socket, ReportedLength, Data);
|
read_until_exhausted(Socket, ReportedLength, Data);
|
||||||
{error, closed} -> log_and_exit(State);
|
{error, closed} -> log_and_exit(State);
|
||||||
{error, timeout} -> log_on_timeout(State)
|
{error, timeout} -> log_on_timeout(State)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% When an EPP message is long, it will be received in smaller chunks.
|
%% When an EPP message is long, it will be received in smaller chunks.
|
||||||
|
@ -156,7 +156,8 @@ read_until_exhausted(Socket, ExpectedLength, Frame) ->
|
||||||
binary:part(Frame,
|
binary:part(Frame,
|
||||||
{byte_size(Frame), 4 - ExpectedLength});
|
{byte_size(Frame), 4 - ExpectedLength});
|
||||||
ExpectedLength > byte_size(Frame) ->
|
ExpectedLength > byte_size(Frame) ->
|
||||||
{ok, NextFrame} = gen_tcp:recv(Socket, 0, ?DefaultTimeout),
|
{ok, NextFrame} = gen_tcp:recv(Socket, 0,
|
||||||
|
?DefaultTimeout),
|
||||||
NewFrame = <<Frame/binary, NextFrame/binary>>,
|
NewFrame = <<Frame/binary, NextFrame/binary>>,
|
||||||
read_until_exhausted(Socket, ExpectedLength, NewFrame)
|
read_until_exhausted(Socket, ExpectedLength, NewFrame)
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue