pub struct ForwardService<'a> { /* private fields */ }Expand description
Port forwarding management via ControlMaster sessions.
Obtained from SshManager::forward().
Implementations§
Source§impl<'a> ForwardService<'a>
impl<'a> ForwardService<'a>
pub fn new(paths: &'a SshPaths) -> Self
Sourcepub async fn list(&self) -> Result<Vec<(ControlSession, Vec<PortForward>)>>
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
Sourcepub async fn list_sessions(&self) -> Result<Vec<ControlSession>>
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.
Sourcepub async fn cancel(&self, control_path: &Path, local_port: u16) -> Result<()>
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.
Sourcepub async fn list_forwards(
&self,
control_path: &Path,
) -> Result<Vec<PortForward>>
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.
Sourcepub async fn cancel_known(
&self,
control_path: &Path,
forward: &PortForward,
) -> Result<()>
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.
Sourcepub async fn exit_session(&self, control_path: &Path) -> Result<()>
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.
Sourcepub async fn conflicting_local_ports(
&self,
) -> Result<HashMap<u16, Vec<PathBuf>>>
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
Sourcepub async fn test_connectivity_with_timeout(
&self,
local_port: u16,
timeout: Duration,
) -> Result<()>
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.
Sourcepub async fn test_connectivity(&self, local_port: u16) -> Result<()>
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.