25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

* src/tls/tls.erl: Updated

SVN Revision: 249
This commit is contained in:
Alexey Shchepin 2004-07-26 22:37:24 +00:00
parent 3377c54ecd
commit e10fc255aa
2 changed files with 47 additions and 6 deletions

View File

@ -1,3 +1,7 @@
2004-07-26 Alexey Shchepin <alexey@sevcom.net>
* src/tls/tls.erl: Updated
2004-07-25 Alexey Shchepin <alexey@sevcom.net>
* src/tls/: Library for TLS support (not completed)

View File

@ -12,7 +12,12 @@
-behaviour(gen_server).
-export([start/0, start_link/0, tcp_to_tls/2, tls_to_tcp/1, test/0]).
-export([start/0, start_link/0,
tcp_to_tls/2, tls_to_tcp/1,
send/2,
recv/2, recv/3,
close/1,
test/0]).
%% Internal exports, call-back functions.
-export([init/1,
@ -101,15 +106,47 @@ recv(Socket, Length) ->
recv(#tlssock{tcpsock = TCPSocket, tlsport = Port}, Length, Timeout) ->
case gen_tcp:recv(TCPSocket, Length, Timeout) of
{ok, Packet} ->
todo;
case port_control(Port, ?SET_ENCRYPTED_INPUT, Packet) of
[0] ->
case port_control(Port, ?GET_DECRYPTED_INPUT, []) of
[0 | In] ->
case port_control(Port, ?GET_ENCRYPTED_OUTPUT, []) of
[0 | Out] ->
case gen_tcp:send(TCPSocket, Out) of
ok ->
{ok, In};
Error ->
Error
end;
[1 | Error] ->
{error, Error}
end;
[1 | Error] ->
{error, Error}
end;
[1 | Error] ->
{error, Error}
end;
{error, _Reason} = Error ->
Error
end.
send(#tlssock) ->
send(#tlssock{tcpsock = TCPSocket, tlsport = Port}, Packet) ->
case port_control(Port, ?SET_DECRYPTED_OUTPUT, Packet) of
[0] ->
case port_control(Port, ?GET_ENCRYPTED_OUTPUT, []) of
[0 | Out] ->
gen_tcp:send(TCPSocket, Out);
[1 | Error] ->
{error, Error}
end;
[1 | Error] ->
{error, Error}
end.
close(#tlssock) ->
close(#tlssock{tcpsock = TCPSocket, tlsport = Port}) ->
gen_tcp:close(TCPSocket),
port_close(Port).
test() ->