Compare commits
3 Commits
main
...
b5c8bf757d
| Author | SHA1 | Date | |
|---|---|---|---|
| b5c8bf757d | |||
| b394f7eb7f | |||
| 15828b697d |
@@ -11,9 +11,9 @@ start_link(Port, CertDir) ->
|
|||||||
supervisor:start_link({local, ?MODULE}, ?MODULE, [Port, CertDir]).
|
supervisor:start_link({local, ?MODULE}, ?MODULE, [Port, CertDir]).
|
||||||
|
|
||||||
init([Port, CertDir]) ->
|
init([Port, CertDir]) ->
|
||||||
SupFlags = #{stragegy => one_for_one,
|
SupFlags = #{strategy => one_for_one,
|
||||||
intensity => 1,
|
intensity => 5,
|
||||||
period => 5},
|
period => 10},
|
||||||
ChildSpecs = [#{id => session_sup,
|
ChildSpecs = [#{id => session_sup,
|
||||||
start => {session_sup, start_link, []},
|
start => {session_sup, start_link, []},
|
||||||
restart => permanent,
|
restart => permanent,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||||
terminate/2, code_change/3]).
|
terminate/2, code_change/3]).
|
||||||
|
|
||||||
-record(state, {socket, acceptor}).
|
-record(state, {socket}).
|
||||||
|
|
||||||
start_link(Port, CertDir) ->
|
start_link(Port, CertDir) ->
|
||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [Port, CertDir], []).
|
gen_server:start_link({local, ?MODULE}, ?MODULE, [Port, CertDir], []).
|
||||||
@@ -30,7 +30,7 @@ handle_cast(_Msg, State) ->
|
|||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
handle_info(accept, State = #state{socket = Socket}) ->
|
handle_info(accept, State = #state{socket = Socket}) ->
|
||||||
case ssl:transport_accept(Socket) of
|
case ssl:transport_accept(Socket, 5000) of
|
||||||
{ok, TlsSocket} ->
|
{ok, TlsSocket} ->
|
||||||
self() ! {handshake, TlsSocket},
|
self() ! {handshake, TlsSocket},
|
||||||
self() ! accept;
|
self() ! accept;
|
||||||
@@ -39,7 +39,7 @@ handle_info(accept, State = #state{socket = Socket}) ->
|
|||||||
end,
|
end,
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_info({handshake, TlsSocket}, State) ->
|
handle_info({handshake, TlsSocket}, State) ->
|
||||||
case ssl:handshake(TlsSocket) of
|
case ssl:handshake(TlsSocket, 5000) of
|
||||||
{ok, ClientSocket} ->
|
{ok, ClientSocket} ->
|
||||||
{ok, Pid} = session_sup:start_session(ClientSocket),
|
{ok, Pid} = session_sup:start_session(ClientSocket),
|
||||||
ok = ssl:controlling_process(ClientSocket, Pid);
|
ok = ssl:controlling_process(ClientSocket, Pid);
|
||||||
|
|||||||
Reference in New Issue
Block a user