Skip to main content

ForwardService

Struct ForwardService 

Source
pub struct ForwardService<'a> { /* private fields */ }
Expand description

Port forwarding management via ControlMaster sessions.

Obtained from SshManager::forward().

Implementations§

Source§

impl<'a> ForwardService<'a>

Source

pub fn new(paths: &'a SshPaths) -> Self

Source

pub async fn list(&self) -> Result<Vec<(ControlSession, Vec<PortForward>)>>

List (session, forwards) pairs in session order; a session whose listing fails is included with an empty list (logged, not propagated).

§Errors

As Self::list_sessions.

Source

pub async fn list_sessions(&self) -> Result<Vec<ControlSession>>

Discover active ControlMaster sessions, verified via ssh -O check.

§Errors

Error::TaskFailed if the directory scan task fails.

Source

pub async fn cancel(&self, control_path: &Path, local_port: u16) -> Result<()>

Cancel the forward on local_port.

§Errors

Error::ForwardNotFound, Error::ForwardFailed (non-UTF-8 path), Error::CommandFailed, or Error::TaskFailed.

Source

pub async fn list_forwards( &self, control_path: &Path, ) -> Result<Vec<PortForward>>

List forwards for the session at control_path.

§Errors

Error::ForwardFailed (non-UTF-8 path), Error::CommandFailed, or Error::TaskFailed.

Source

pub async fn cancel_known( &self, control_path: &Path, forward: &PortForward, ) -> Result<()>

Cancel a known forward, skipping the list round-trip.

§Errors

Error::ForwardFailed (non-UTF-8 path), Error::CommandFailed, or Error::TaskFailed.

Source

pub async fn exit_session(&self, control_path: &Path) -> Result<()>

Gracefully shut down a ControlMaster session (ssh -O exit).

§Errors

Error::ForwardFailed (non-UTF-8 path), Error::CommandFailed, or Error::TaskFailed.

Source

pub async fn conflicting_local_ports( &self, ) -> Result<HashMap<u16, Vec<PathBuf>>>

Map each local port claimed by more than one session to the control socket paths claiming it.

§Errors

As Self::list_sessions.

Source

pub async fn test_connectivity_with_timeout( &self, local_port: u16, timeout: Duration, ) -> Result<()>

Connect to 127.0.0.1:<local_port> within timeout; proves only that the local socket accepts — not end-to-end forwarding to the remote side.

§Errors

Error::ForwardFailed on timeout or connect failure.

Source

pub async fn test_connectivity(&self, local_port: u16) -> Result<()>

test_connectivity_with_timeout with the default 2s timeout; local-acceptance only, not end-to-end.

§Errors

As Self::test_connectivity_with_timeout.

Auto Trait Implementations§

§

impl<'a> Freeze for ForwardService<'a>

§

impl<'a> RefUnwindSafe for ForwardService<'a>

§

impl<'a> Send for ForwardService<'a>

§

impl<'a> Sync for ForwardService<'a>

§

impl<'a> Unpin for ForwardService<'a>

§

impl<'a> UnsafeUnpin for ForwardService<'a>

§

impl<'a> UnwindSafe for ForwardService<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more