diff options
author | Fredrik Gustafsson <[email protected]> | 2012-12-19 11:54:09 +0100 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2012-12-19 11:54:09 +0100 |
commit | b5bfeb6de3a2a79c9581d779112d1cc192225dbd (patch) | |
tree | 3151cdb378e62a3d05f849492ce6c84382355cd3 /lib/ssh/src/ssh_connection_manager.erl | |
parent | 3bd2ba0060f9bcb0d3bddd74a4a5763e520a533f (diff) | |
parent | c228ceb941e26a04317bd2f66a2ee64687f0f869 (diff) | |
download | otp-b5bfeb6de3a2a79c9581d779112d1cc192225dbd.tar.gz otp-b5bfeb6de3a2a79c9581d779112d1cc192225dbd.tar.bz2 otp-b5bfeb6de3a2a79c9581d779112d1cc192225dbd.zip |
Merge branch 'fredrik/ssh/rekeying'
* fredrik/ssh/rekeying:
ssh_basic_SUITE rekey test modifications
Modifications to idle_time testcase
Added test for rekeying
Added doc for rekey_limit option
Renegotiating every hour and every gb sent, can be decreased with option {rekey_limit, integer()}
Diffstat (limited to 'lib/ssh/src/ssh_connection_manager.erl')
-rw-r--r-- | lib/ssh/src/ssh_connection_manager.erl | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/ssh/src/ssh_connection_manager.erl b/lib/ssh/src/ssh_connection_manager.erl index 0c1eee5186..94a9ed505f 100644 --- a/lib/ssh/src/ssh_connection_manager.erl +++ b/lib/ssh/src/ssh_connection_manager.erl @@ -125,7 +125,8 @@ info(ConnectionManager, ChannelProcess) -> %% or amount of data sent counter! renegotiate(ConnectionManager) -> cast(ConnectionManager, renegotiate). - +renegotiate_data(ConnectionManager) -> + cast(ConnectionManager, renegotiate_data). connection_info(ConnectionManager, Options) -> call(ConnectionManager, {connection_info, Options}). @@ -481,7 +482,9 @@ handle_cast({global_request, _, _, _, _} = Request, State0) -> handle_cast(renegotiate, #state{connection = Pid} = State) -> ssh_connection_handler:renegotiate(Pid), {noreply, State}; - +handle_cast(renegotiate_data, #state{connection = Pid} = State) -> + ssh_connection_handler:renegotiate_data(Pid), + {noreply, State}; handle_cast({adjust_window, ChannelId, Bytes}, #state{connection = Pid, connection_state = #connection{channel_cache = Cache}} = State) -> @@ -520,6 +523,8 @@ handle_info({start_connection, server, Exec = proplists:get_value(exec, Options), CliSpec = proplists:get_value(ssh_cli, Options, {ssh_cli, [Shell]}), ssh_connection_handler:send_event(Connection, socket_control), + erlang:send_after(3600000, self(), rekey), + erlang:send_after(60000, self(), rekey_data), {noreply, State#state{connection = Connection, connection_state = CState#connection{address = Address, @@ -536,6 +541,8 @@ handle_info({start_connection, client, case (catch ssh_transport:connect(Parent, Address, Port, SocketOpts, Options)) of {ok, Connection} -> + erlang:send_after(60000, self(), rekey_data), + erlang:send_after(3600000, self(), rekey), {noreply, State#state{connection = Connection}}; Reason -> Pid ! {self(), not_connected, Reason}, @@ -568,8 +575,15 @@ handle_info({'DOWN', _Ref, process, ChannelPid, _Reason}, State) -> %%% So that terminate will be run when supervisor is shutdown handle_info({'EXIT', _Sup, Reason}, State) -> - {stop, Reason, State}. - + {stop, Reason, State}; +handle_info(rekey, State) -> + renegotiate(self()), + erlang:send_after(3600000, self(), rekey), + {noreply, State}; +handle_info(rekey_data, State) -> + renegotiate_data(self()), + erlang:send_after(60000, self(), rekey_data), + {noreply, State}. handle_password(Opts) -> handle_rsa_password(handle_dsa_password(handle_normal_password(Opts))). handle_normal_password(Opts) -> |