pub struct SSHServer<'a> { /* private fields */ }Expand description
An async SSH server instance
The run() method runs the session to completion, with application behaviour
defined by the ServBehaviour instance.
Once the client has opened sessions, those can be retrieved with stdio()
and stdio_stderr() methods.
This is async executor agnostic, though requires the ServBehaviour instance
to be wrapped in a SunsetMutex.
Implementations§
Source§impl<'a> SSHServer<'a>
impl<'a> SSHServer<'a>
pub fn new(inbuf: &'a mut [u8], outbuf: &'a mut [u8]) -> Result<Self>
Sourcepub async fn run<S: ServBehaviour>(
&self,
rsock: &mut impl Read,
wsock: &mut impl Write,
b: &SunsetMutex<S>,
) -> Result<()>
pub async fn run<S: ServBehaviour>( &self, rsock: &mut impl Read, wsock: &mut impl Write, b: &SunsetMutex<S>, ) -> Result<()>
Runs the session to completion.
rsock and wsock are the SSH network channel (TCP port 22 or equivalent).
b is an instance of ServBehaviour which defines application behaviour.
Sourcepub async fn stdio(&'a self, ch: ChanHandle) -> Result<ChanInOut<'a>>
pub async fn stdio(&'a self, ch: ChanHandle) -> Result<ChanInOut<'a>>
Returns a ChanInOut representing a channel.
For a shell this is stdin/stdout, for other channel types it is the only
data type.
ch is the ChanHandle passed to the application’s Behaviour
methods.
Sourcepub async fn stdio_stderr(
&'a self,
ch: ChanHandle,
) -> Result<(ChanInOut<'a>, ChanOut<'a>)>
pub async fn stdio_stderr( &'a self, ch: ChanHandle, ) -> Result<(ChanInOut<'a>, ChanOut<'a>)>
Retrieve the stdin/stdout/stderr streams.
If stderr is not required, use stdio() instead to avoid needing to poll
the returned stderr.
The session will block until the streams are drained (they use the session buffer),
so they must be drained if used.