0.34.6_repo_cleanup

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-22 09:31:15 +02:00
1 parent ce1a90397c
commit 133d2f0f91
273 files changed
+5969 -6926

No files matched your search

+9 -44
View File
@@ -51,7 +51,6 @@ struct Cli {
default_value = "/var/lib/rustproxy"
)]
data_dir: PathBuf,
/// Use an existing JSON file as canonical desired configuration.
#[arg(long, global = true, env = "RUST_PROXY_CONFIG")]
config: Option<PathBuf>,
#[arg(
@@ -65,13 +64,10 @@ struct Cli {
update_repository_url: Option<String>,
#[arg(long, global = true, env = "RUST_PROXY_UPDATE_VERSION_URL")]
update_version_url: Option<String>,
/// Seconds between release checks. Set to 0 to disable automatic checks.
#[arg(long, global = true, env = "RUST_PROXY_UPDATE_CHECK_INTERVAL_SECS")]
update_check_interval_secs: Option<u64>,
/// Deprecated compatibility no-op kept so older systemd units continue to start.
#[arg(long = "accept-remote-admin-risk", global = true, hide = true)]
_accept_remote_admin_risk: bool,
/// Interactive varnishlog-style live request view from all vhosts.
#[arg(long, global = true)]
livelogs: bool,
#[command(subcommand)]
@@ -79,28 +75,21 @@ struct Cli {
}
#[derive(Subcommand)]
enum Command {
/// Start proxy and local administration listener.
Serve(ServeOptions),
/// Soft reload configuration and certificate files in the running service.
Reload,
/// Compatibility alias for `admin setup-token`; never an API access token.
Token,
/// Local administrator setup, password recovery and session management.
Admin {
#[command(subcommand)]
action: AdminCommand,
},
/// Manage local certificate files and hot-reload certificate bindings.
Tls {
#[command(subcommand)]
action: TlsCommand,
},
/// Read or replace configuration through the running admin API.
Config {
#[command(subcommand)]
action: ConfigCommand,
},
/// Create or restore a password-encrypted full application backup.
Backup {
#[command(subcommand)]
action: BackupCommand,
@@ -108,58 +97,46 @@ enum Command {
}
#[derive(Subcommand)]
enum AdminCommand {
/// Create the sole administrator. Requires ownership of the private data directory.
Init {
#[arg(long)]
username: Option<String>,
#[arg(long)]
password_stdin: bool,
},
/// Replace the administrator password and revoke all sessions, online or offline.
ResetPassword {
#[arg(long)]
password_stdin: bool,
},
/// Generate or print the one-time setup capability, only before an administrator exists.
SetupToken,
/// Report whether administrator setup is complete (no credentials printed).
Status,
/// Revoke all browser/CLI sessions without changing the password.
LogoutAll,
}
#[derive(Subcommand)]
enum ConfigCommand {
/// Print desired configuration as JSON (suitable for `config apply`).
Get,
/// Revalidate and hot-publish the current configuration and certificate files.
Reload,
/// Atomically validate, save and apply a full configuration document.
Apply { file: PathBuf },
/// Validate JSON, ACLs, headers and backend policy without changing the database.
Validate { file: PathBuf },
}
#[derive(Subcommand)]
enum BackupCommand {
/// Create an encrypted full backup. Safe while RustProxy is serving.
Create {
/// Destination .rpb file. Existing files are never overwritten.
#[arg(long)]
output: Option<PathBuf>,
},
/// Restore an encrypted full backup atomically. Stop the RustProxy service first.
Restore { archive: PathBuf },
Restore {
archive: PathBuf,
},
}
#[derive(Subcommand)]
enum TlsCommand {
/// Generate a self-signed development certificate. Existing files are never overwritten.
Generate {
#[arg(long)]
name: String,
#[arg(long, value_delimiter = ',', required = true)]
hosts: Vec<String>,
},
/// Import a matching PEM certificate/key pair under a new name.
Import {
#[arg(long)]
name: String,
@@ -168,8 +145,6 @@ enum TlsCommand {
#[arg(long)]
key: PathBuf,
},
/// Stage an externally issued pair (for example Certbot) and atomically
/// switch an existing manual certificate id to it through the running API.
Deploy {
#[arg(long)]
id: String,
@@ -178,12 +153,10 @@ enum TlsCommand {
#[arg(long)]
key: PathBuf,
},
/// Reload configured certificate files without restarting listeners.
Reload,
}
#[derive(Args)]
struct ServeOptions {
/// Optional HTTPS listener. dev.sh enables 127.0.0.1:8443 unless RUST_PROXY_TLS=0.
#[arg(long, env = "RUST_PROXY_TLS_LISTEN")]
tls_listen: Option<SocketAddr>,
#[arg(
@@ -200,25 +173,19 @@ struct ServeOptions {
max_connections: usize,
#[arg(long, default_value_t = 256)]
max_inflight: usize,
/// Includes upload time until upstream response headers arrive.
#[arg(long, default_value_t = 120)]
upstream_timeout_secs: u64,
#[arg(long, default_value_t = 60)]
body_idle_timeout_secs: u64,
/// Inactivity in either direction; independent of ordinary HTTP bodies.
#[arg(long, default_value_t = 300)]
websocket_idle_timeout_secs: u64,
#[arg(long, default_value_t = 10)]
shutdown_timeout_secs: u64,
/// Permit an administration listener on an unspecified address such as 0.0.0.0.
#[arg(long)]
allow_remote_admin: bool,
}
#[cfg(target_os = "linux")]
fn disable_transparent_huge_pages() {
// Keep THP policy local to RustProxy. Large 2 MiB anonymous pages amplify
// allocator fragmentation/retention for the long-running proxy workload, so
// opt this process out before Tokio creates worker threads and their heaps.
let result = unsafe { libc::prctl(libc::PR_SET_THP_DISABLE, 1, 0, 0, 0) };
if result != 0 {
eprintln!(
@@ -237,8 +204,6 @@ fn main() -> Result<()> {
.enable_all()
.build()?;
let result = runtime.block_on(application());
// OS getaddrinfo workers cannot be killed by cancelling their future.
// Bound runtime shutdown after listeners and application tasks have drained.
runtime.shutdown_timeout(Duration::from_secs(2));
result
}
@@ -293,9 +258,6 @@ async fn application() -> Result<()> {
)
.with(rust_proxy::logging::ErrorLogLayer::new(error_log))
.init();
// Rust's default panic hook writes directly to stderr, bypassing tracing
// and the configured error file. Route worker panics through the same
// WARN/ERROR sink as other diagnostics without duplicate journald output.
std::panic::set_hook(Box::new(|info| {
let payload = if let Some(value) = info.payload().downcast_ref::<&str>() {
(*value).to_owned()
@@ -355,7 +317,12 @@ async fn application() -> Result<()> {
.context("a subcommand is required (or use --livelogs)")?;
match command {
Command::Reload => {
config_command(resolve_installed_data_dir(cli.data_dir, data_dir_explicit), cli.admin_listen, ConfigCommand::Reload).await
config_command(
resolve_installed_data_dir(cli.data_dir, data_dir_explicit),
cli.admin_listen,
ConfigCommand::Reload,
)
.await
}
Command::Token => {
admin_command(
@@ -400,8 +367,6 @@ async fn application() -> Result<()> {
cli.update_version_url,
cli.update_check_interval_secs,
)?;
// Server startup never guesses a data directory. Package/service/plugin
// installation must pass its configured path explicitly.
run(
cli.data_dir,
cli.admin_listen,