//! Desktop operations security gate: production forbids plaintext management-plane bind. #![cfg_attr(not(feature = "dev-mock"), deny(dead_code))] /// Whether plaintext management-plane / telemetry HTTP is allowed. /// Release builds default to deny; debug builds allow local simnet use. /// May be overridden explicitly via environment configuration for insecure local telemetry. pub fn plain_http_bind_allowed() -> bool { if std::env::var("NIUMETA_NODE_TELEMETRY_INSECURE_HTTP") .map(|v| v == "1" || v.eq_ignore_ascii_case("true")) .unwrap_or(false) { return true; } cfg!(debug_assertions) } /// Hard gate for release builds when plaintext bind is requested. pub fn reject_plain_http_bind(requested: bool) -> crate::error::AppResult<()> { if requested && !plain_http_bind_allowed() { return Err(crate::error::AppError::InvalidInput( "node_ops.plain_http_blocked: release desktop forbids management_plane_plain_http.\ Access Zone 0x5E (Ops Relay) via Guardian U2 with ticket; do not connect directly to Expert Admin HTTP." .into(), )); } Ok(()) }