ssh2-python icon indicating copy to clipboard operation
ssh2-python copied to clipboard

Write bindings for libssh2_channel_direct_streamlocal

Open imgurbot12 opened this issue 7 years ago • 2 comments

I noticed this has been added recently added to the libssh2 library and was wondering if it could be wrapped and accessible through this as well.

Here is the pull request to show the changes in libssh2: https://github.com/libssh2/libssh2/pull/216

I have never worked with cpython before, otherwise i would make a pull request with the changes myself but i imagine the code in session.pyx would look something like this:

def channel_direct_streamlocal(self, socket_path not None, shost not None, int sport):
        cdef c_ssh2.LIBSSH2_CHANNEL *channel
        cdef bytes b_shost = to_bytes(shost)
        cdef bytes b_socket_path = to_bytes(socket_path)
        cdef char *_shost = b_shost
        cdef char *_socket_path = b_socket_path
        with nogil:
            channel = c_ssh2.libssh2_channel_direct_streamlocal(
                self._session, _socket_path, _shost, sport)
        if channel is NULL:
            return handle_error_codes(c_ssh2.libssh2_session_last_errno(
                self._session))
        return PyChannel(channel, self)

Thanks

imgurbot12 avatar Sep 27 '18 23:09 imgurbot12

Hi there,

Thanks for the interest and report.

It can be added after the pull request has been accepted and merged into libssh2, yes. It has not been merged yet - depends on libssh2/libssh2#216

The implementation looks ok more or less (indentation) if you want to make a PR for when it is merged into libssh2.

pkittenis avatar Oct 03 '18 12:10 pkittenis

PR has been merged: https://github.com/libssh2/libssh2/pull/945

enkore avatar Nov 10 '23 23:11 enkore