diff options
author | Ingela Anderton Andin <[email protected]> | 2014-06-12 11:00:05 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2014-06-12 11:00:05 +0200 |
commit | dc7a9868aa1259f729f8437d92a7948ba1098401 (patch) | |
tree | 4042e83b991607c341136374f63e9c186b7a993b /lib/ssh/src/ssh.erl | |
parent | 0ce0df2b41c47735ec342853b305041394423633 (diff) | |
parent | f7ca16604b567d19078a3edb7c9ba84ffa33a2dc (diff) | |
download | otp-dc7a9868aa1259f729f8437d92a7948ba1098401.tar.gz otp-dc7a9868aa1259f729f8437d92a7948ba1098401.tar.bz2 otp-dc7a9868aa1259f729f8437d92a7948ba1098401.zip |
Merge branch 'ia/ssh/inet-option/OTP-11976' into maint
* ia/ssh/inet-option/OTP-11976:
ssh: Handle inet and inet6 option correctly
Diffstat (limited to 'lib/ssh/src/ssh.erl')
-rw-r--r-- | lib/ssh/src/ssh.erl | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl index 240de69eff..bf7ba0be7f 100644 --- a/lib/ssh/src/ssh.erl +++ b/lib/ssh/src/ssh.erl @@ -74,8 +74,7 @@ connect(Host, Port, Options, Timeout) -> {_, Transport, _} = TransportOpts = proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}), ConnectionTimeout = proplists:get_value(connect_timeout, Options, infinity), - Inet = proplists:get_value(inet, SshOptions, inet), - try Transport:connect(Host, Port, [ {active, false}, Inet | SocketOptions], ConnectionTimeout) of + try Transport:connect(Host, Port, [ {active, false} | SocketOptions], ConnectionTimeout) of {ok, Socket} -> Opts = [{user_pid, self()}, {host, Host} | fix_idle_time(SshOptions)], ssh_connection_handler:start_connection(client, Socket, Opts, Timeout); @@ -256,8 +255,8 @@ do_start_daemon(Host, Port, Options, SocketOptions) -> handle_options(Opts) -> try handle_option(proplists:unfold(Opts), [], []) of - {_,_} = Options -> - Options + {Inet, Ssh} -> + {handle_ip(Inet), Ssh} catch throw:Error -> Error @@ -436,8 +435,9 @@ handle_inet_option({active, _} = Opt) -> throw({error, {{eoptions, Opt}, "Ssh has built in flow control, " "and activ is handled internaly user is not allowd" "to specify this option"}}); -handle_inet_option({inet, Value} = Opt) when (Value == inet) or (Value == inet6) -> - Opt; + +handle_inet_option({inet, Value}) when (Value == inet) or (Value == inet6) -> + Value; handle_inet_option({reuseaddr, _} = Opt) -> throw({error, {{eoptions, Opt},"Is set internaly user is not allowd" "to specify this option"}}); @@ -460,3 +460,17 @@ handle_pref_algs([H|T], Acc) -> _ -> false end. + +handle_ip(Inet) -> %% Default to ipv4 + case lists:member(inet, Inet) of + true -> + Inet; + false -> + case lists:member(inet6, Inet) of + true -> + Inet; + false -> + [inet | Inet] + end + end. + |