From 6f87cc21ebc83d04d7fa1035f33d9b3a92855239 Mon Sep 17 00:00:00 2001 From: "dzianis.lituyeu" Date: Tue, 26 May 2026 13:06:18 +0300 Subject: [PATCH] Fix config namings --- Dockerfile | 2 +- README.md | 26 +++++++++---------- benchmarks/compose.yml | 2 +- .../{tiny-proxy.caddy => tiny-proxy.conf} | 0 config.caddy => config.conf | 0 docker-compose.yml | 4 +-- examples/background.rs | 2 +- examples/basic.rs | 4 +-- examples/{example.caddy => example.conf} | 0 examples/hot_reload.rs | 4 +-- examples/{simple.caddy => simple.conf} | 0 examples/{tls.caddy => tls.conf} | 0 examples/tls.rs | 2 +- file.caddy => file.conf | 0 src/api/mod.rs | 2 +- src/api/server.rs | 2 +- src/cli/args.rs | 2 +- src/lib.rs | 6 ++--- src/proxy/proxy.rs | 10 +++---- 19 files changed, 34 insertions(+), 34 deletions(-) rename benchmarks/proxies/{tiny-proxy.caddy => tiny-proxy.conf} (100%) rename config.caddy => config.conf (100%) rename examples/{example.caddy => example.conf} (100%) rename examples/{simple.caddy => simple.conf} (100%) rename examples/{tls.caddy => tls.conf} (100%) rename file.caddy => file.conf (100%) diff --git a/Dockerfile b/Dockerfile index 73ecb5d..1620ceb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,4 +40,4 @@ VOLUME /etc/tiny-proxy VOLUME /etc/ssl/tiny-proxy ENTRYPOINT ["tiny-proxy"] -CMD ["-c", "/etc/tiny-proxy/config.caddy"] +CMD ["-c", "/etc/tiny-proxy/config.conf"] diff --git a/README.md b/README.md index 749fcb1..f7223f4 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ cargo install --path . # Or build and run directly cargo build --release -./target/release/tiny-proxy --config config.caddy +./target/release/tiny-proxy --config config.conf ``` ### As Library @@ -56,13 +56,13 @@ docker pull ghcr.io/denislituev/tiny-proxy:latest # Run with a local config docker run -d \ -p 8080:8080 \ - -v $(pwd)/config.caddy:/etc/tiny-proxy/config.caddy:ro \ + -v $(pwd)/config.conf:/etc/tiny-proxy/config.conf:ro \ ghcr.io/denislituev/tiny-proxy:latest # With TLS docker run -d \ -p 8443:8443 \ - -v $(pwd)/config.caddy:/etc/tiny-proxy/config.caddy:ro \ + -v $(pwd)/config.conf:/etc/tiny-proxy/config.conf:ro \ -v $(pwd)/certs:/etc/ssl/tiny-proxy:ro \ ghcr.io/denislituev/tiny-proxy:latest ``` @@ -76,7 +76,7 @@ services: ports: - "8080:8080" volumes: - - ./config.caddy:/etc/tiny-proxy/config.caddy:ro + - ./config.conf:/etc/tiny-proxy/config.conf:ro ``` See [`docker-compose.yml`](docker-compose.yml) for a full example with TLS + echo backends. @@ -99,15 +99,15 @@ Run as standalone server: ```bash # Auto-detect listeners from config (recommended) -tiny-proxy --config config.caddy +tiny-proxy --config config.conf # Or specify a single listen address -tiny-proxy --config config.caddy --addr 127.0.0.1:8080 +tiny-proxy --config config.conf --addr 127.0.0.1:8080 ``` #### CLI Arguments -- `--config, -c`: Path to configuration file (default: `./file.caddy`) +- `--config, -c`: Path to configuration file (default: `./file.conf`) - `--addr, -a`: Optional. Bind a **single** listener on this address (plain `start()`). When omitted, **auto-detect mode** (`start_all()`): one listener per site address in config. TLS sites → HTTPS with SNI; non-TLS → HTTP. In auto-detect mode only, each TLS port also @@ -124,7 +124,7 @@ use tiny_proxy::{Config, Proxy}; #[tokio::main] async fn main() -> anyhow::Result<()> { // Load configuration from file - let config = Config::from_file("config.caddy")?; + let config = Config::from_file("config.conf")?; // Create and start proxy let proxy = Proxy::new(config); @@ -144,7 +144,7 @@ use std::sync::Arc; #[tokio::main] async fn main() -> anyhow::Result<()> { - let config = Config::from_file("config.caddy")?; + let config = Config::from_file("config.conf")?; let proxy = Arc::new(Proxy::new(config)); // Spawn proxy in background @@ -179,7 +179,7 @@ use tokio::sync::RwLock; #[tokio::main] async fn main() -> anyhow::Result<()> { - let config = Config::from_file("config.caddy")?; + let config = Config::from_file("config.conf")?; let proxy = Proxy::new(config); // Get shared config handle for hot-reload @@ -193,7 +193,7 @@ async fn main() -> anyhow::Result<()> { }); // Update config at runtime — takes effect immediately - let new_config = Config::from_file("new-config.caddy")?; + let new_config = Config::from_file("new-config.conf")?; { let mut guard = config_handle.write().await; *guard = new_config; @@ -207,7 +207,7 @@ async fn main() -> anyhow::Result<()> { Or use the built-in `update_config` method: ```rust -let new_config = Config::from_file("updated-config.caddy")?; +let new_config = Config::from_file("updated-config.conf")?; proxy.update_config(new_config).await; ``` @@ -497,7 +497,7 @@ use tiny_proxy::api; use std::sync::Arc; use tokio::sync::RwLock; -let config = Arc::new(RwLock::new(Config::from_file("config.caddy")?)); +let config = Arc::new(RwLock::new(Config::from_file("config.conf")?)); api::start_api_server("127.0.0.1:8081", config).await?; ``` diff --git a/benchmarks/compose.yml b/benchmarks/compose.yml index 3858e44..f18854e 100644 --- a/benchmarks/compose.yml +++ b/benchmarks/compose.yml @@ -35,7 +35,7 @@ services: - "8080:8080" - "8443:8443" volumes: - - ./proxies/tiny-proxy.caddy:/etc/tiny-proxy/config.caddy:ro + - ./proxies/tiny-proxy.conf:/etc/tiny-proxy/config.conf:ro - ./certs:/etc/ssl/tiny-proxy:ro depends_on: - backend diff --git a/benchmarks/proxies/tiny-proxy.caddy b/benchmarks/proxies/tiny-proxy.conf similarity index 100% rename from benchmarks/proxies/tiny-proxy.caddy rename to benchmarks/proxies/tiny-proxy.conf diff --git a/config.caddy b/config.conf similarity index 100% rename from config.caddy rename to config.conf diff --git a/docker-compose.yml b/docker-compose.yml index 4e473ee..c06023a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ # Example stack: tiny-proxy (TLS + HTTP→HTTPS redirect) with internal echo backends. # # Backends are reachable only inside the compose network (no host ports). -# Config: config.caddy — HTTPS :8443, redirect :8080 (8443 - 443 + 80). +# Config: config.conf — HTTPS :8443, redirect :8080 (8443 - 443 + 80). # # Usage: # mkdir -p certs @@ -23,7 +23,7 @@ services: - "8443:8443" # HTTPS (TLS termination) - "8080:8080" # HTTP → HTTPS redirect volumes: - - ./config.caddy:/etc/tiny-proxy/config.caddy:ro + - ./config.conf:/etc/tiny-proxy/config.conf:ro - ./certs:/etc/ssl/tiny-proxy:ro depends_on: backend-users: diff --git a/examples/background.rs b/examples/background.rs index 929bbdf..3e8acd9 100644 --- a/examples/background.rs +++ b/examples/background.rs @@ -27,7 +27,7 @@ async fn main() -> anyhow::Result<()> { info!("Starting tiny-proxy background example"); // Load configuration from file - let config = Config::from_file("file.caddy")?; + let config = Config::from_file("file.conf")?; info!("Loaded configuration for {} site(s)", config.sites.len()); diff --git a/examples/basic.rs b/examples/basic.rs index 2207fd5..ec53b4a 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -24,8 +24,8 @@ async fn main() -> anyhow::Result<()> { info!("Starting tiny-proxy library example"); // Load configuration from file - // Make sure file.caddy exists in the project root or provide a different path - let config = Config::from_file("file.caddy")?; + // Make sure file.conf exists in the project root or provide a different path + let config = Config::from_file("file.conf")?; info!("Loaded configuration for {} site(s)", config.sites.len()); diff --git a/examples/example.caddy b/examples/example.conf similarity index 100% rename from examples/example.caddy rename to examples/example.conf diff --git a/examples/hot_reload.rs b/examples/hot_reload.rs index c77e6c1..1d77c1f 100644 --- a/examples/hot_reload.rs +++ b/examples/hot_reload.rs @@ -12,7 +12,7 @@ //! cargo run --example hot_reload //! ``` //! -//! Then edit file.caddy while the proxy is running to see hot-reload in action. +//! Then edit file.conf while the proxy is running to see hot-reload in action. use tiny_proxy::{Config, Proxy}; use tokio::time::{sleep, Duration}; @@ -28,7 +28,7 @@ async fn main() -> anyhow::Result<()> { info!("Starting tiny-proxy hot-reload example"); - let config_path = "file.caddy"; + let config_path = "file.conf"; // Load initial configuration from file let config = Config::from_file(config_path)?; diff --git a/examples/simple.caddy b/examples/simple.conf similarity index 100% rename from examples/simple.caddy rename to examples/simple.conf diff --git a/examples/tls.caddy b/examples/tls.conf similarity index 100% rename from examples/tls.caddy rename to examples/tls.conf diff --git a/examples/tls.rs b/examples/tls.rs index bbd656d..604555e 100644 --- a/examples/tls.rs +++ b/examples/tls.rs @@ -41,7 +41,7 @@ async fn main() -> anyhow::Result<()> { info!("Starting tiny-proxy TLS example"); - let config = Config::from_file("examples/tls.caddy")?; + let config = Config::from_file("examples/tls.conf")?; info!("Loaded configuration for {} site(s)", config.sites.len()); let proxy = Proxy::new(config); diff --git a/file.caddy b/file.conf similarity index 100% rename from file.caddy rename to file.conf diff --git a/src/api/mod.rs b/src/api/mod.rs index 5ad4e58..6a27b50 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -13,7 +13,7 @@ //! //! # #[tokio::main] //! # async fn main() -> anyhow::Result<()> { -//! let config = Arc::new(RwLock::new(Config::from_file("config.caddy")?)); +//! let config = Arc::new(RwLock::new(Config::from_file("config.conf")?)); //! //! // Start the management API server //! api::start_api_server("127.0.0.1:8081", config).await?; diff --git a/src/api/server.rs b/src/api/server.rs index 715fef1..1299a85 100644 --- a/src/api/server.rs +++ b/src/api/server.rs @@ -38,7 +38,7 @@ use crate::error::Result; /// # use std::sync::Arc; /// # #[tokio::main] /// # async fn main() -> anyhow::Result<()> { -/// let config = Arc::new(tokio::sync::RwLock::new(Config::from_file("config.caddy")?)); +/// let config = Arc::new(tokio::sync::RwLock::new(Config::from_file("config.conf")?)); /// api::server::start_api_server("127.0.0.1:8081", config).await?; /// # Ok(()) /// # } diff --git a/src/cli/args.rs b/src/cli/args.rs index 011be80..b50dc02 100644 --- a/src/cli/args.rs +++ b/src/cli/args.rs @@ -5,7 +5,7 @@ use clap::Parser; #[command(author, version, about, long_about = None)] pub struct Cli { /// Path to configuration file (Caddy-like format) - #[arg(short, long, default_value = "./file.caddy")] + #[arg(short, long, default_value = "./file.conf")] pub config: String, /// Address for proxy server to listen on. diff --git a/src/lib.rs b/src/lib.rs index 00ef2f8..f28bf6d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ //! #[tokio::main] //! async fn main() -> anyhow::Result<()> { //! // Load configuration from file -//! let config = Config::from_file("config.caddy")?; +//! let config = Config::from_file("config.conf")?; //! //! // Create and start proxy //! let proxy = Proxy::new(config); @@ -38,7 +38,7 @@ //! //! #[tokio::main] //! async fn main() -> anyhow::Result<()> { -//! let config = Config::from_file("config.caddy")?; +//! let config = Config::from_file("config.conf")?; //! let proxy = Proxy::new(config); //! //! // Spawn proxy in background @@ -60,7 +60,7 @@ //! When built as a binary, the proxy can be run from command line: //! //! ```bash -//! tiny-proxy --config config.caddy --addr 127.0.0.1:8080 +//! tiny-proxy --config config.conf --addr 127.0.0.1:8080 //! ``` //! //! ## Configuration Format diff --git a/src/proxy/proxy.rs b/src/proxy/proxy.rs index 78d00b5..1d6cd6b 100644 --- a/src/proxy/proxy.rs +++ b/src/proxy/proxy.rs @@ -32,7 +32,7 @@ use crate::proxy::handler::proxy; /// /// #[tokio::main] /// async fn main() -> anyhow::Result<()> { -/// let config = Config::from_file("file.caddy")?; +/// let config = Config::from_file("file.conf")?; /// let proxy = Proxy::new(config); /// proxy.start("127.0.0.1:8080").await?; /// Ok(()) @@ -48,7 +48,7 @@ use crate::proxy::handler::proxy; /// /// #[tokio::main] /// async fn main() -> anyhow::Result<()> { -/// let config = Config::from_file("config.caddy")?; +/// let config = Config::from_file("config.conf")?; /// let proxy = Proxy::new(config); /// /// // Get a handle to the shared config for hot-reload @@ -62,7 +62,7 @@ use crate::proxy::handler::proxy; /// }); /// /// // Later, update config at runtime -/// let new_config = Config::from_file("updated-config.caddy")?; +/// let new_config = Config::from_file("updated-config.conf")?; /// { /// let mut guard = config_handle.write().await; /// *guard = new_config; @@ -193,7 +193,7 @@ impl Proxy { /// # use tiny_proxy::{Config, Proxy}; /// # #[tokio::main] /// # async fn main() -> anyhow::Result<()> { - /// # let config = Config::from_file("config.caddy")?; + /// # let config = Config::from_file("config.conf")?; /// # let proxy = Proxy::new(config); /// proxy.start("127.0.0.1:8080").await?; /// # Ok(()) @@ -270,7 +270,7 @@ impl Proxy { /// # use tiny_proxy::{Config, Proxy}; /// # #[tokio::main] /// # async fn main() -> anyhow::Result<()> { - /// # let config = Config::from_file("config.caddy")?; + /// # let config = Config::from_file("config.conf")?; /// # let proxy = std::sync::Arc::new(Proxy::new(config)); /// proxy.start_all().await?; /// # Ok(())