crates/gunnar-front/src/egress_door.rs
//! **The egress door's gate** (AIRGAP B2, owner rule 2026-10-25).
//!
//! The door (nordisk-pairing `egress::serve`, opened by [`crate::pid1`]) is an outbound
//! CONNECT proxy: main and the twin, laid with no public IPv4, leave through this front to
//! TLS ports on outside addresses. That is an outbound surface, so it opens only in a front
//! built with `egress-door` AND started with `GUNNAR_FRONT_EGRESS=on`. Every front row names
//! the feature and every front medium sets the switch (gunnar-recipe), so a live or sold lean
//! estate keeps its way out.
/// The switch.
pub const ENV: &str = "GUNNAR_FRONT_EGRESS";
/// Pure: does the switch's value open the door, in a build that has it at all?
pub fn switch(value: Option<&str>) -> bool {
cfg!(feature = "egress-door") && value.is_some_and(|v| v.trim().eq_ignore_ascii_case("on"))
}
/// Whether this front opens its egress door (the build and the environment, read now).
pub fn open_here() -> bool {
switch(std::env::var(ENV).ok().as_deref())
}
/// What the front says when the door stays shut.
pub const SHUT: &str = "front: the egress door is off (AIRGAP: it needs the `egress-door` feature and GUNNAR_FRONT_EGRESS=on) — a box with no public IPv4 reaches nothing outside the estate";
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_door_needs_the_build_and_the_switch() {
assert!(!switch(None));
assert!(!switch(Some("off")));
assert!(!switch(Some("")));
assert_eq!(switch(Some(" ON ")), cfg!(feature = "egress-door"));
}
}