// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. //! The compiled runtime config read by ianitor-edge. Produced only by [`crate::compile::edge`]. //! Edge never decides policy: everything it does is spelled out here. Secret values are never //! part of it, only secret names, resolved by edge from `$CREDENTIALS_DIRECTORY`. use serde::{Deserialize, Serialize}; /// Bumped on any incompatible change; edge refuses other versions. pub const EDGE_CONFIG_VERSION: u32 = 1; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeConfig { pub version: u32, /// Plain-HTTP listener: ACME HTTP-01 challenges and redirects to HTTPS. pub http_listen: String, /// TLS listener serving every host by SNI. pub https_listen: String, /// Port used in HTTP→HTTPS redirects (omitted from `Location` when 443). pub https_port: u16, /// Directory holding Domi certificates as `.crt` / `.key`. pub cert_dir: String, /// Edge state; ACME account and certificates live in `/acme`. pub state_dir: String, /// Access log file (JSON lines). Only hosts with `access_log` enabled write to it. pub access_log: String, pub acme: Option, pub forward_auth: Option, /// Sorted by hostname. pub hosts: Vec, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeAcme { pub directory: String, pub email: Option, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeForwardAuth { pub upstream: EdgeUpstream, pub path_and_query: String, pub copy_headers: Vec, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeUpstream { /// `host:port`, IPv6 in brackets. pub address: String, pub tls: bool, /// SNI and certificate name when `tls` is set. pub sni: String, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "snake_case", tag = "source")] pub enum EdgeTls { /// Obtain and renew through ACME; stored under `/acme`. Acme, /// Load from files (Domi CA certificates). Files { cert: String, key: String }, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "snake_case", tag = "kind")] pub enum EdgeValue { Literal { value: String }, Secret { name: String }, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "snake_case", tag = "op")] pub enum EdgeHeaderOp { Set { name: String, value: EdgeValue }, Remove { name: String }, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeHealthCheck { pub path: String, pub interval_secs: u32, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeHost { pub hostname: String, pub tls: EdgeTls, pub upstreams: Vec, pub forward_auth: bool, pub websockets: bool, pub request_headers: Vec, pub response_headers: Vec, pub health_check: Option, pub access_log: bool, }