openssh-rust / openssh

Scriptable SSH through OpenSSH in Rust
Apache License 2.0
232 stars 35 forks source link

Make Session function public for external calls #124

Closed baoyachi closed 1 year ago

baoyachi commented 1 year ago

Currently, I have implemented a Session object myself. Can these two methods be opened for external self control calls.

Make new_process_mux or new_native_mux public .


mpl Session {
    #[cfg(feature = "process-mux")]
+    pub(super) fn new_process_mux(tempdir: TempDir) -> Self {
        Self(SessionImp::ProcessImpl(process_impl::Session::new(tempdir)))
    }

    #[cfg(feature = "native-mux")]
+    pub(super) fn new_native_mux(tempdir: TempDir) -> Self {
        Self(SessionImp::NativeMuxImpl(native_mux_impl::Session::new(
            tempdir,
        )))
    }
}

About code link ref:

NobodyXu commented 1 year ago

You can use Session::{resume, resume_mux}, which might be enough for your use case.

NobodyXu commented 1 year ago

If it's not enough, then we can make them public

baoyachi commented 1 year ago

@NobodyXu Because the internal implementation of the resume method is to set TempDir to None, but currently, I need external control to pass this tempdir to Sesson internally.

native_mux_impl link ref process_impl

So, I really hope these two methods are publicly available.

NobodyXu commented 1 year ago

@baoyachi I will accept a PR for this with enough documentation on how to use it.

baoyachi commented 1 year ago

I will send PR later to solve this issue too.