pub struct Monitor { /* private fields */ }Expand description
The live monitor.
Implementations§
Source§impl Monitor
impl Monitor
Sourcepub async fn bind(cfg: &Config) -> Result<Self>
pub async fn bind(cfg: &Config) -> Result<Self>
Open the listening socket, if this arrangement needs one.
A failure to bind is fatal, exactly as in autossh: without the listener the loop can never complete and every probe would fail.
pub fn enabled(&self) -> bool
Sourcepub fn listener_fd(&self) -> Option<RawFd>
pub fn listener_fd(&self) -> Option<RawFd>
The descriptor the monitor listens on, if it has one.
Exposed so a test can assert it is close-on-exec: were the forked ssh to inherit it, the port or socket would stay held after rash exited.
Sourcepub fn next_forwards(&self) -> Vec<OsString>
pub fn next_forwards(&self) -> Vec<OsString>
The forwards for the next ssh start.
For the UNIX arrangement the remote socket path is different every time.
A socket left behind on the remote by an unclean disconnect would stop
sshd binding it, and StreamLocalBindUnlink defaults to no on the
server — which a client cannot override. Without a fresh path, rash
would restart for ever against a forward that could never come up.
Trait Implementations§
Source§impl Drop for Monitor
impl Drop for Monitor
Source§fn drop(&mut self)
fn drop(&mut self)
Take the sockets away on the way out.
Binding already unlinks a stale file, so a leftover cannot break the next run — but without this the directory accumulates a dead pair per run, indefinitely. The pid file has the same guard, and the same limitation: a process killed with SIGKILL runs no destructors, so the next bind’s unlink is still the thing that guarantees correctness.