0.34.6_repo_cleanup
This commit is contained in:
1 parent
ce1a90397c
commit
133d2f0f91
273 files changed
+5969
-6926
No files matched your search
+38
-23
@@ -68,7 +68,6 @@ async fn run(
|
||||
listeners: initial_listeners,
|
||||
..Config::default()
|
||||
};
|
||||
// Only a NEW database receives this neutral landing page.
|
||||
config.pages.direct_ip = Some(Default::default());
|
||||
config.pages.unknown_host = Some(Default::default());
|
||||
config
|
||||
@@ -76,14 +75,24 @@ async fn run(
|
||||
let store = Store::open(&data_dir.join("config.sqlite3"), &initial).await?;
|
||||
let mut saved = store.load().await?;
|
||||
let external = if let Some(path) = file_config {
|
||||
Some((path.clone(), rust_proxy::runtime::external_config::read(&path)?))
|
||||
} else { None };
|
||||
Some((
|
||||
path.clone(),
|
||||
rust_proxy::runtime::external_config::read(&path)?,
|
||||
))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let saved_revision = saved.revision;
|
||||
let stored_document = serde_json::to_value(&saved.config)?;
|
||||
if let Some((_, (config, _))) = &external { saved.config = config.clone(); }
|
||||
if let Some((_, (config, _))) = &external {
|
||||
saved.config = config.clone();
|
||||
}
|
||||
startup_locks.ensure_config(&mut saved.config);
|
||||
let changed_on_disk = external.is_some() && serde_json::to_value(&saved.config)? != stored_document;
|
||||
if changed_on_disk { saved.revision = saved.revision.checked_add(1).context("revision overflow")?; }
|
||||
let changed_on_disk =
|
||||
external.is_some() && serde_json::to_value(&saved.config)? != stored_document;
|
||||
if changed_on_disk {
|
||||
saved.revision = saved.revision.checked_add(1).context("revision overflow")?;
|
||||
}
|
||||
startup_locks
|
||||
.validate(&saved.config, startup_admin_addr)
|
||||
.context("stored configuration conflicts with a listener fixed by systemd/startup")?;
|
||||
@@ -110,8 +119,6 @@ async fn run(
|
||||
data_dir: Some(data_dir.clone()),
|
||||
};
|
||||
saved.config.listeners.validate(&resolved_policy)?;
|
||||
// The certificate library is available even on an HTTP-only installation.
|
||||
// Initializing private files does not bind or expose a TLS listener.
|
||||
let directory = data_dir.join("certs");
|
||||
let initialize = directory.clone();
|
||||
tokio::task::spawn_blocking(move || rust_proxy::tls::initialize_default(&initialize)).await??;
|
||||
@@ -139,8 +146,12 @@ async fn run(
|
||||
.await?
|
||||
.context("stored configuration is invalid; no automatic reset was performed")?;
|
||||
if changed_on_disk {
|
||||
ensure!(store.replace_as(saved_revision, &snapshot.envelope.config, "file-startup").await?,
|
||||
"configuration history changed while loading --config");
|
||||
ensure!(
|
||||
store
|
||||
.replace_as(saved_revision, &snapshot.envelope.config, "file-startup")
|
||||
.await?,
|
||||
"configuration history changed while loading --config"
|
||||
);
|
||||
}
|
||||
rust_proxy::logging::configure_error_log(snapshot.envelope.config.error_log.clone());
|
||||
let admin_tls_config = {
|
||||
@@ -159,7 +170,10 @@ async fn run(
|
||||
}
|
||||
let renewal_observations = store.load_certificate_renewals().await?;
|
||||
let geoip_format = snapshot.envelope.config.geoip_updates.format;
|
||||
let geoip = match rust_proxy::geoip::Database::load_format(&data_dir.join("geoip"), geoip_format) {
|
||||
let geoip = match rust_proxy::geoip::Database::load_format(
|
||||
&data_dir.join("geoip"),
|
||||
geoip_format,
|
||||
) {
|
||||
Ok(database) => std::sync::Arc::new(database),
|
||||
Err(error) => {
|
||||
tracing::warn!(%error, "GeoIP country database unavailable; country allow lists fail closed");
|
||||
@@ -179,11 +193,13 @@ async fn run(
|
||||
startup_locks,
|
||||
geoip,
|
||||
);
|
||||
if let Some((path, (_, hash))) = external { state.set_config_file(path, hash).await; }
|
||||
state.prometheus_token_hash.store(store.prometheus_token_hash().await?.map(Arc::new));
|
||||
if let Some((path, (_, hash))) = external {
|
||||
state.set_config_file(path, hash).await;
|
||||
}
|
||||
state
|
||||
.prometheus_token_hash
|
||||
.store(store.prometheus_token_hash().await?.map(Arc::new));
|
||||
state.acme.restore_renewals(renewal_observations);
|
||||
// Bind EVERY listener before spawning servers: a missing private IP or
|
||||
// occupied port fails startup atomically, never falling back to 0.0.0.0.
|
||||
let mut public_listeners = Vec::new();
|
||||
for binding in &state.active_listeners {
|
||||
if options.demo {
|
||||
@@ -269,9 +285,6 @@ async fn run(
|
||||
} else {
|
||||
None
|
||||
};
|
||||
// Release checks are control-plane best effort only. Start them after every
|
||||
// socket has bound successfully so DNS/network failures can never obscure or
|
||||
// interfere with listener startup failures.
|
||||
state.start_geoip_updates();
|
||||
state.start_dns_acl_updates();
|
||||
state.start_update_check(update_check);
|
||||
@@ -448,7 +461,10 @@ async fn run(
|
||||
grace
|
||||
};
|
||||
if managed_update {
|
||||
tracing::info!(budget_seconds = cache_flush_budget.as_secs(), "managed-update hot-to-cold cache handoff started");
|
||||
tracing::info!(
|
||||
budget_seconds = cache_flush_budget.as_secs(),
|
||||
"managed-update hot-to-cold cache handoff started"
|
||||
);
|
||||
}
|
||||
let flush_result = if managed_update {
|
||||
tokio::time::timeout(
|
||||
@@ -460,10 +476,9 @@ async fn run(
|
||||
tokio::time::timeout(cache_flush_budget, state.cache.flush_hot_to_cold()).await
|
||||
};
|
||||
match flush_result {
|
||||
Ok(moved) if managed_update => tracing::info!(
|
||||
moved,
|
||||
"managed-update hot-to-cold cache handoff completed"
|
||||
),
|
||||
Ok(moved) if managed_update => {
|
||||
tracing::info!(moved, "managed-update hot-to-cold cache handoff completed")
|
||||
}
|
||||
Ok(moved) if moved > 0 => tracing::info!(
|
||||
moved,
|
||||
"flushed hot cache objects to cold storage before shutdown"
|
||||
|
||||
Reference in new issue
Block a user