Skip to main content

TunnelState

Struct TunnelState 

Source
pub struct TunnelState {
Show 19 fields pub list: Vec<TunnelRule>, pub form: TunnelForm, pub active: HashMap<String, ActiveTunnel>, pub form_baseline: Option<TunnelFormBaseline>, pub pending_delete: Option<usize>, pub summaries_cache: HashMap<String, String>, pub sort_mode: TunnelSortMode, pub parser_tx: Sender<ParserMessage>, pub parser_rx: Receiver<ParserMessage>, pub lsof_tx: Sender<LsofMessage>, pub lsof_rx: Receiver<LsofMessage>, pub clients: HashMap<u16, Vec<ClientPeer>>, pub conflicts: HashMap<u16, PortConflict>, pub last_lsof_at: Option<Instant>, pub peer_viz: HashMap<(u16, String), [u64; 12]>, pub peer_viz_last_push: Option<Instant>, pub peer_viz_prev_push: Option<Instant>, pub lsof: Option<LsofPollerHandle>, pub demo_live_snapshots: HashMap<String, TunnelLiveSnapshot>,
}
Expand description

Tunnel-owned state grouped off the App god-struct. Contains the rule list, the edit form, the live child-process map, form baseline for the dirty check, the pending delete index and the cached per-host summary strings. Pure state container; behaviour lives on App or on dedicated methods here.

Fields§

§list: Vec<TunnelRule>§form: TunnelForm§active: HashMap<String, ActiveTunnel>§form_baseline: Option<TunnelFormBaseline>§pending_delete: Option<usize>§summaries_cache: HashMap<String, String>§sort_mode: TunnelSortMode

Sort mode for the tunnels overview screen. Cycled by s.

§parser_tx: Sender<ParserMessage>§parser_rx: Receiver<ParserMessage>§lsof_tx: Sender<LsofMessage>§lsof_rx: Receiver<LsofMessage>§clients: HashMap<u16, Vec<ClientPeer>>§conflicts: HashMap<u16, PortConflict>§last_lsof_at: Option<Instant>§peer_viz: HashMap<(u16, String), [u64; 12]>

Per-peer rolling braille history, pushed once per lsof poll arrival from poll(). Keyed by (bind_port, peer.src) so it survives wholesale clients replacements as long as the peer is still in the new snapshot. Each cell carries one current_rx_bps + current_tx_bps snapshot from a single lsof poll, so the visible window covers PEER_VIZ_BUCKETS polls (~24-48s on Linux/macOS).

§peer_viz_last_push: Option<Instant>

Wall-clock of the most recent push_peer_viz rotation, and the one before it. The renderer divides (now - last) / (last - prev) to derive a smooth phase in [0, 1] that drifts the wave leftward by exactly one bucket between pushes — adaptive to the actual poll interval (which varies on macOS due to nettop overhead).

§peer_viz_prev_push: Option<Instant>§lsof: Option<LsofPollerHandle>§demo_live_snapshots: HashMap<String, TunnelLiveSnapshot>

Demo / test seed. When App.demo_mode == true the detail panel reads from this map instead of the live counters, so visual regression tests are byte-deterministic.

Implementations§

Source§

impl TunnelState

Source

pub fn request_delete(&mut self, idx: usize)

Open a delete confirmation for the tunnel at idx. The renderer reads pending_delete to draw the confirm overlay.

Source

pub fn cancel_delete(&mut self)

Dismiss a pending delete confirmation. Idempotent.

Source

pub fn ensure_lsof_poller(&mut self)

Ensure the shared lsof poller is running. Idempotent: a second call after the poller is already up is a noop. Caller is responsible for updating bind_ports afterwards.

Source

pub fn set_lsof_ports(&self, ports: Vec<(String, u16, u32)>)

Replace the lsof poller’s port list. Callers compute the (alias, bind_port, tunnel_pid) tuples from the SSH config directives because ActiveTunnel does not store the rule set directly. The poller picks up the new list on its next iteration.

Source

pub fn poll(&mut self) -> Vec<(String, String, bool)>

Drain the parser channel into per-tunnel live state, drain the lsof channel into the shared clients and conflicts maps, rotate per-tunnel history buckets and finally poll every active child for exit. Returns (alias, message, is_error) tuples so the outer loop can route them through notify_*.

Source

pub fn push_peer_viz(&mut self, now: Instant)

Push one bucket of per-peer braille history. Called exactly once per lsof arrival so the visible window encodes PEER_VIZ_BUCKETS consecutive poll snapshots — long enough to see the trend, short enough to react quickly to changes. The renderer fills in smooth motion between pushes via peer_viz_last_push / peer_viz_prev_push. Garbage-collects entries for peers that no longer appear in self.clients.

Trait Implementations§

Source§

impl Default for TunnelState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for TunnelState

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V