[edge] Reload and share links: in-process config swap with self-reverting trials, admin socket with health and certificate status, share-link cookies, visitor pages and throttle

This commit is contained in:
2026-11-07 17:49:53 +01:00
parent c0ed9c65c5
commit 6ce1fe9d2b
18 changed files with 2137 additions and 186 deletions
+14 -1
View File
@@ -14,9 +14,14 @@ use rustls::sign::CertifiedKey;
use rustls_pki_types::pem::PemObject;
use rustls_pki_types::{CertificateDer, PrivateKeyDer};
/// Lives as long as the process: Domi certificates are replaced as a set on every reload,
/// ACME certificates are added by the ACME service and kept across reloads.
#[derive(Debug, Default)]
pub struct CertStore {
/// ACME certificates (and anything inserted one by one).
certs: ArcSwap<HashMap<String, Arc<CertifiedKey>>>,
/// Domi certificates of the current config.
files: ArcSwap<HashMap<String, Arc<CertifiedKey>>>,
}
impl CertStore {
@@ -29,8 +34,13 @@ impl CertStore {
});
}
/// Replace the Domi certificates (on reload).
pub fn replace_files(&self, files: HashMap<String, Arc<CertifiedKey>>) {
self.files.store(Arc::new(files));
}
pub fn has(&self, host: &str) -> bool {
self.certs.load().contains_key(host)
self.files.load().contains_key(host) || self.certs.load().contains_key(host)
}
}
@@ -38,6 +48,9 @@ impl ResolvesServerCert for CertStore {
fn resolve(&self, hello: ClientHello<'_>) -> Option<Arc<CertifiedKey>> {
// No SNI or an unknown name: no certificate, the handshake fails (as with Caddy).
let name = hello.server_name()?.to_ascii_lowercase();
if let Some(k) = self.files.load().get(&name) {
return Some(k.clone());
}
self.certs.load().get(&name).cloned()
}
}