Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Changes
* `ssh2.sftp_handle.SFTPHandle.closed` is now a public property indicating whether `ssh2.sftp_handle.SFTPHandle.close`
was called on a `SFTPHandle` or not.
* Added `ssh2.channel.Channel.signal` function for sending signals over SSH to an open channel - #221
* Added `ssh2.session.Session.direct_streamlocal_ex` for creating `Channel` objects tunneling a local UNIX socket
via the remote host to a third party.


1.1.2
Expand Down
18 changes: 18 additions & 0 deletions ci/integration_tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,21 @@ def test_non_blocking_multi_chan(self):
def test_userauth_kb_with_callback(self):
my_cb = MagicMock()
self.assertRaises(AuthenticationError, self.session.userauth_keyboardinteractive_callback, self.user, my_cb)

def test_direct_streamlocal(self):
unix_sock_path = '/tmp/my_sock'
try:
os.unlink(unix_sock_path)
except OSError:
pass
unix_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
unix_sock.bind(unix_sock_path)
try:
unix_sock.listen(1)
self.assertEqual(self._auth(), 0)
chan = self.session.direct_streamlocal_ex(unix_sock_path, '127.0.0.1', 12345)
self.assertTrue(chan is not None)
self.assertIsInstance(chan, Channel)
finally:
unix_sock.close()
os.unlink(unix_sock_path)
3 changes: 3 additions & 0 deletions ssh2/c_ssh2.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ cdef extern from "libssh2.h" nogil:
LIBSSH2_CHANNEL *libssh2_channel_direct_tcpip(
LIBSSH2_SESSION *session, const char *host,
int port)
LIBSSH2_CHANNEL *libssh2_channel_direct_streamlocal_ex(
LIBSSH2_SESSION * session, const char *socket_path,
const char *shost, int sport)
LIBSSH2_LISTENER *libssh2_channel_forward_listen_ex(
LIBSSH2_SESSION *session, const char *host,
int port, int *bound_port, int queue_maxsize)
Expand Down
Loading