Permalink
Browse files

Correct SSL relaying

  • Loading branch information...
1 parent 8d60b45 commit 42be2a7cdbb91060e30b51b2d4a9ddd902f2b267 @jhs jhs committed Dec 1, 2010
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/somdune_net.erl
View
10 src/somdune_net.erl
@@ -258,14 +258,18 @@ relay(FromSocket, ToSocket, Bytes) ->
tcp_setopts(FromSocket, [{packet, 0}, {active, once} ]),
tcp_setopts(ToSocket, [{packet, 0}, {active, once} ]),
receive
- {tcp, FromSocket, Data} ->
+ {Type, FromSocket, Data} when Type == tcp orelse Type == ssl ->
tcp_send(ToSocket, Data),
relay(FromSocket, ToSocket, Bytes);
- {tcp, ToSocket, Data} ->
+ {Type, ToSocket, Data} when Type == tcp orelse Type == ssl ->
tcp_send(FromSocket, Data),
relay(FromSocket, ToSocket, Bytes + size(Data));
{tcp_closed, _} ->
- { ok, Bytes }
+ { ok, Bytes };
+ {ssl_closed, _} ->
+ { ok, Bytes };
+ Else ->
+ log_error("Relay error: ~p", [Else])
after
30000 ->
{ error, timeout }

0 comments on commit 42be2a7

Please sign in to comment.