Skip to content

Commit

Permalink
proxy: make tcp closure stop gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
RTUnreal committed May 14, 2024
1 parent 92dea09 commit 332d426
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions service/proxy/lib/proxy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,26 @@ defmodule Proxy do
end

defp loop_sender(socket, conn) do
receive do
{:tcp, s, data} ->
case s do
^socket ->
:gen_tcp.send(conn, data)

^conn ->
:gen_tcp.send(socket, data)
end
if (receive do
{:tcp, s, data} ->
case s do
^socket ->
:gen_tcp.send(conn, data)

^conn ->
:gen_tcp.send(socket, data)
end

true

{:tcp_closed, _s} ->
false
end) do
loop_sender(socket, conn)
else
:gen_tcp.close(conn)
throw("connection closed")
end

loop_sender(socket, conn)
end

defp handle_rfc1929_auth(socket) do
Expand Down

0 comments on commit 332d426

Please sign in to comment.