This commit is contained in:
Mateusz Gruszczyński committed 2026-11-15 13:45:15 +01:00
1 parent df0e39b899
commit 21aef61dd5
35 files changed
+1360 -100

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
static HEADLESS: std::sync::OnceLock<crate::settings::Listeners> = std::sync::OnceLock::new();
pub fn enable_headless(listeners: crate::settings::Listeners) -> bool {
HEADLESS.set(listeners).is_ok()
}
pub fn headless_enabled() -> bool {
HEADLESS.get().is_some()
}
pub fn headless_listeners() -> Option<&'static crate::settings::Listeners> {
HEADLESS.get()
}
pub fn ensure_headless_supported(config: &config::Config) -> anyhow::Result<()> {
if let Some(certificate) = config.tls.certificates.iter().find(|certificate| {
certificate
.issuer
.as_ref()
.is_some_and(|issuer| issuer.auto_renew)
}) {
anyhow::bail!(
"certificate {} uses ACME auto-renewal, which needs the administration panel; in headless mode renew it externally (for example with certbot) and reference the files in cert_file/key_file",
certificate.id
);
}
Ok(())
}
static LAST_RELOAD: std::sync::Mutex<Option<(i64, Option<String>)>> = std::sync::Mutex::new(None);
pub fn record_headless_reload(error: Option<String>) {
if let Ok(mut slot) = LAST_RELOAD.lock() {
*slot = Some((crate::auth::now(), error));
}
}
fn last_headless_reload() -> serde_json::Value {
match LAST_RELOAD.lock().ok().and_then(|slot| slot.clone()) {
Some((at, error)) => json!({ "ok": error.is_none(), "at_unix": at, "error": error }),
None => serde_json::Value::Null,
}
}