Skip to content

Commit bccaaf4

Browse files
committed
Enable introspection of sessions
Adds the session? predicate for testing for a Session object, an the session-hostname and session-port functions for querying a session.
1 parent 3e9f3f4 commit bccaaf4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/clj_ssh/ssh.clj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@
123123
[session]
124124
(protocols/session session))
125125

126+
(defn session?
127+
"Predicate to test for a session"
128+
[x]
129+
(satisfies? x protocols/Session))
130+
126131
;;; Agent
127132
(defn ssh-agent
128133
"Create a ssh-agent. By default a system ssh-agent is preferred."
@@ -323,6 +328,16 @@ keys. All other option key pairs will be passed as SSH config options."
323328
password
324329
(session-options options)))
325330

331+
(defn ^String session-hostname
332+
"Return the hostname for a session"
333+
[^Session session]
334+
(.getHost session))
335+
336+
(defn ^int session-port
337+
"Return the port for a session"
338+
[^Session session]
339+
(.getPort session))
340+
326341
(defn forward-remote-port
327342
"Start remote port forwarding"
328343
([^Session session remote-port local-port ^String local-host]

0 commit comments

Comments
 (0)