104 lines
3.5 KiB
Rust
104 lines
3.5 KiB
Rust
// 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 `<hostname>.crt` / `<hostname>.key`.
|
|
pub cert_dir: String,
|
|
/// Edge state; ACME account and certificates live in `<state_dir>/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<EdgeAcme>,
|
|
pub forward_auth: Option<EdgeForwardAuth>,
|
|
/// Sorted by hostname.
|
|
pub hosts: Vec<EdgeHost>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct EdgeAcme {
|
|
pub directory: String,
|
|
pub email: Option<String>,
|
|
}
|
|
|
|
#[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<String>,
|
|
}
|
|
|
|
#[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 `<state_dir>/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<EdgeUpstream>,
|
|
pub forward_auth: bool,
|
|
pub websockets: bool,
|
|
pub request_headers: Vec<EdgeHeaderOp>,
|
|
pub response_headers: Vec<EdgeHeaderOp>,
|
|
pub health_check: Option<EdgeHealthCheck>,
|
|
pub access_log: bool,
|
|
}
|