Remove dead_code annotations and add #[non_exhaustive] to public enums

All #[allow(dead_code)] annotations on now-used items have been removed
(acceptor.rs, acme.rs, config.rs, static_config.rs). #[non_exhaustive]
added to TlsMode, ProxyError, AdminSocketError, and ValidationError
with wildcard match arms in main.rs for the non-exhaustive enums.
This commit is contained in:
2026-06-12 05:12:32 +00:00
parent 516efb0403
commit cbcd746c9f
8 changed files with 11 additions and 19 deletions

View File

@@ -14,6 +14,7 @@ use crate::shutdown::GracefulShutdown;
use crate::config::ConfigReloadHandle;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum AdminSocketError {
#[error("admin socket disabled (empty path)")]
Disabled,

View File

@@ -1,6 +1,5 @@
use serde::Deserialize;
#[allow(dead_code)]
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct StaticConfig {
pub listeners: Vec<ListenerConfig>,
@@ -28,7 +27,6 @@ pub fn default_shutdown_timeout_secs() -> u64 {
30
}
#[allow(dead_code)]
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct ListenerConfig {
pub bind_addr: String,
@@ -41,17 +39,14 @@ pub struct ListenerConfig {
pub sites: Vec<crate::config::dynamic_config::SiteConfig>,
}
#[allow(dead_code)]
fn default_http_port() -> u32 {
80
}
#[allow(dead_code)]
fn default_https_port() -> u16 {
443
}
#[allow(dead_code)]
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct TlsConfig {
pub mode: String,
@@ -69,12 +64,10 @@ pub struct TlsConfig {
pub key_path: String,
}
#[allow(dead_code)]
fn default_acme_directory() -> String {
"production".to_string()
}
#[allow(dead_code)]
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct LoggingConfig {
#[serde(default = "default_log_level")]
@@ -85,12 +78,10 @@ pub struct LoggingConfig {
pub log_file_path: Option<String>,
}
#[allow(dead_code)]
fn default_log_level() -> String {
"info".to_string()
}
#[allow(dead_code)]
fn default_log_format() -> String {
"text".to_string()
}

View File

@@ -7,6 +7,7 @@ use super::dynamic_config::DynamicConfig;
use super::static_config::StaticConfig;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ValidationError {
#[error("at least one listener must be defined")]
NoListeners,

View File

@@ -120,6 +120,7 @@ async fn run_server(loaded_config: cli::LoadedConfig, config_path: &str) -> Resu
AdminSocketError::Io(e) => {
error!("admin socket IO error: {}", e);
}
_ => {}
}
}
});
@@ -183,6 +184,12 @@ async fn run_server(loaded_config: cli::LoadedConfig, config_path: &str) -> Resu
"ACME TLS configured"
);
}
_ => {
warn!(
addr = %listener_config.bind_addr,
"unsupported TLS mode"
);
}
}
}

View File

@@ -2,6 +2,7 @@ use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ProxyError {
#[error("Bad Gateway")]
BadGateway { host: String, upstream: String },

View File

@@ -12,7 +12,6 @@ use crate::shutdown::GracefulShutdown;
const ACME_TLS_ALPN_01: &[u8] = b"acme-tls/1";
#[allow(dead_code)]
fn build_acme_server_config(
resolver: Arc<rustls_acme::ResolvesServerCertAcme>,
) -> Result<Arc<ServerConfig>> {
@@ -31,8 +30,8 @@ fn build_acme_server_config(
Ok(Arc::new(config))
}
#[allow(dead_code)]
#[derive(Debug)]
#[non_exhaustive]
pub enum TlsMode {
Manual(Arc<ServerConfig>),
Acme {
@@ -41,7 +40,6 @@ pub enum TlsMode {
},
}
#[allow(dead_code)]
pub fn setup_tls(tls_config: &TlsConfig, shutdown: Arc<GracefulShutdown>) -> Result<TlsMode> {
match tls_config.mode.as_str() {
"manual" => {

View File

@@ -8,13 +8,10 @@ use tracing::{error, info, warn};
use crate::shutdown::GracefulShutdown;
#[allow(dead_code)]
const LETS_ENCRYPT_PRODUCTION_DIRECTORY: &str = "https://acme-v02.api.letsencrypt.org/directory";
#[allow(dead_code)]
const LETS_ENCRYPT_STAGING_DIRECTORY: &str =
"https://acme-staging-v02.api.letsencrypt.org/directory";
#[allow(dead_code)]
pub struct AcmeTlsConfig {
pub domains: Vec<String>,
pub cache_dir: PathBuf,
@@ -22,7 +19,6 @@ pub struct AcmeTlsConfig {
pub contact: Vec<String>,
}
#[allow(dead_code)]
pub struct AcmeTlsSetup {
pub resolver: Arc<ResolvesServerCertAcme>,
pub state: AcmeState<std::io::Error, std::io::Error>,
@@ -54,7 +50,6 @@ impl AcmeTlsConfig {
Ok(AcmeTlsSetup { resolver, state })
}
#[allow(dead_code)]
pub fn directory_url(&self) -> &str {
match self.directory.as_str() {
"production" => LETS_ENCRYPT_PRODUCTION_DIRECTORY,
@@ -64,7 +59,6 @@ impl AcmeTlsConfig {
}
}
#[allow(dead_code)]
pub fn spawn_acme_state(
state: AcmeState<std::io::Error, std::io::Error>,
domains: Vec<String>,

View File

@@ -14,7 +14,6 @@ use rustls::ServerConfig;
use rustls::SupportedCipherSuite;
use rustls_pemfile;
#[allow(dead_code)]
static RESTRICTED_CIPHER_SUITES: &[SupportedCipherSuite] = &[
cipher_suite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
cipher_suite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,