aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/ssh.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2013-10-28 16:12:29 +0100
committerHans Nilsson <[email protected]>2013-10-28 16:12:29 +0100
commit207a13a549052e014a82362032995e347ffb68ff (patch)
tree93a94f73c882ab25f9ed3c7fddd4f5237551bd9b /lib/ssh/src/ssh.erl
parent609e1414a0685c2082d30f9d5c50ca65209a1236 (diff)
parentf5495aa1560daf65c063a8d5b99a5ea17520ea92 (diff)
downloadotp-207a13a549052e014a82362032995e347ffb68ff.tar.gz
otp-207a13a549052e014a82362032995e347ffb68ff.tar.bz2
otp-207a13a549052e014a82362032995e347ffb68ff.zip
Merge branch 'hans/ssh/srcip/OTP-11339' into maint
* hans/ssh/srcip/OTP-11339: ssh: Add ssh:sockname/1 incl doc and tests ssh: Add function ssh:peername/1 with test
Diffstat (limited to 'lib/ssh/src/ssh.erl')
-rw-r--r--lib/ssh/src/ssh.erl24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl
index 7d5478c3f6..80d20abbbd 100644
--- a/lib/ssh/src/ssh.erl
+++ b/lib/ssh/src/ssh.erl
@@ -28,6 +28,8 @@
-export([start/0, start/1, stop/0, connect/3, connect/4, close/1, connection_info/2,
channel_info/3,
daemon/1, daemon/2, daemon/3,
+ peername/1,
+ sockname/1,
stop_listener/1, stop_listener/2, stop_daemon/1, stop_daemon/2,
shell/1, shell/2, shell/3]).
@@ -245,6 +247,28 @@ shell(Host, Port, Options) ->
end.
%%--------------------------------------------------------------------
+%% Function: peername(ConnectionRef) -> {ok, {Host,Port}}
+%% | {error,Error}
+%%
+%% Description: Returns the peer address of the connection
+%%--------------------------------------------------------------------
+peername(ConnectionRef) ->
+ [{peer, {_Name,{IP,Port}}}] =
+ ssh_connection_manager:connection_info(ConnectionRef, [peer]),
+ {ok, {IP,Port}}.
+
+%%--------------------------------------------------------------------
+%% Function: sockname(ConnectionRef) -> {ok, {Host,Port}}
+%% | {error,Error}
+%%
+%% Description: Returns the local address of the connection
+%%--------------------------------------------------------------------
+sockname(ConnectionRef) ->
+ [{sockname, Result}] =
+ ssh_connection_manager:connection_info(ConnectionRef, [sockname]),
+ Result.
+
+%%--------------------------------------------------------------------
%%% Internal functions
%%--------------------------------------------------------------------
fix_idle_time(SshOptions) ->