diff --git a/.bleep b/.bleep index 23752af..eb738a9 100644 --- a/.bleep +++ b/.bleep @@ -1 +1 @@ -3eb2a9750ec02867bec91a4069796faae8cd860c \ No newline at end of file +a5e77a0c20967fd9ff223682be0fc043a6f35514 \ No newline at end of file diff --git a/pingora-core/Cargo.toml b/pingora-core/Cargo.toml index 6efad9a..496e401 100644 --- a/pingora-core/Cargo.toml +++ b/pingora-core/Cargo.toml @@ -35,7 +35,6 @@ http = { workspace = true } log = { workspace = true } h2 = { workspace = true } lru = { workspace = true } -nix = "~0.24.3" clap = { version = "3.2.25", features = ["derive"] } once_cell = { workspace = true } serde = { version = "1.0", features = ["derive"] } @@ -46,7 +45,6 @@ libc = "0.2.70" chrono = { version = "~0.4.31", features = ["alloc"], default-features = false } thread_local = "1.0" prometheus = "0.13" -daemonize = "0.5.0" sentry = { version = "0.26", features = [ "backtrace", "contexts", @@ -69,12 +67,21 @@ tokio-test = "0.4" zstd = "0" httpdate = "1" +[target.'cfg(unix)'.dependencies] +daemonize = "0.5.0" +nix = "~0.24.3" + +[target.'cfg(windows)'.dependencies] +windows-sys = { version = "0.59.0", features = ["Win32_Networking_WinSock"] } + [dev-dependencies] matches = "0.1" env_logger = "0.9" reqwest = { version = "0.11", features = ["rustls"], default-features = false } -hyperlocal = "0.8" hyper = "0.14" + +[target.'cfg(unix)'.dev-dependencies] +hyperlocal = "0.8" jemallocator = "0.5" [features] diff --git a/pingora-core/tests/test_basic.rs b/pingora-core/tests/test_basic.rs index 9842009..ace35cb 100644 --- a/pingora-core/tests/test_basic.rs +++ b/pingora-core/tests/test_basic.rs @@ -15,6 +15,7 @@ mod utils; use hyper::Client; +#[cfg(unix)] use hyperlocal::{UnixClientExt, Uri}; use utils::init; @@ -51,6 +52,7 @@ async fn test_https_http2() { assert_eq!(res.version(), reqwest::Version::HTTP_11); } +#[cfg(unix)] #[cfg(feature = "some_tls")] #[tokio::test] async fn test_uds() { diff --git a/pingora-core/tests/utils/mod.rs b/pingora-core/tests/utils/mod.rs index 8a26684..46f050f 100644 --- a/pingora-core/tests/utils/mod.rs +++ b/pingora-core/tests/utils/mod.rs @@ -78,6 +78,7 @@ fn entry_point(opt: Option) { my_server.bootstrap(); let mut listeners = Listeners::tcp("0.0.0.0:6145"); + #[cfg(unix)] listeners.add_uds("/tmp/echo.sock", None); let mut tls_settings = diff --git a/pingora-pool/src/connection.rs b/pingora-pool/src/connection.rs index e5a9655..ce60e17 100644 --- a/pingora-pool/src/connection.rs +++ b/pingora-pool/src/connection.rs @@ -27,7 +27,10 @@ use tokio::sync::{oneshot, watch, Notify, OwnedMutexGuard}; use super::lru::Lru; type GroupKey = u64; +#[cfg(unix)] type ID = i32; +#[cfg(windows)] +type ID = usize; /// the metadata of a connection #[derive(Clone, Debug)] diff --git a/pingora-proxy/Cargo.toml b/pingora-proxy/Cargo.toml index a672867..b94711d 100644 --- a/pingora-proxy/Cargo.toml +++ b/pingora-proxy/Cargo.toml @@ -41,7 +41,6 @@ reqwest = { version = "0.11", features = [ ], default-features = false } tokio-test = "0.4" env_logger = "0.9" -hyperlocal = "0.8" hyper = "0.14" tokio-tungstenite = "0.20.1" pingora-limits = { version = "0.3.0", path = "../pingora-limits" } @@ -52,6 +51,9 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_yaml = "0.8" +[target.'cfg(unix)'.dev-dependencies] +hyperlocal = "0.8" + [features] default = ["openssl"] openssl = ["pingora-core/openssl", "pingora-cache/openssl"] diff --git a/pingora-proxy/tests/test_basic.rs b/pingora-proxy/tests/test_basic.rs index 744f9b7..2be27e4 100644 --- a/pingora-proxy/tests/test_basic.rs +++ b/pingora-proxy/tests/test_basic.rs @@ -15,6 +15,7 @@ mod utils; use hyper::{body::HttpBody, header::HeaderValue, Body, Client}; +#[cfg(unix)] use hyperlocal::{UnixClientExt, Uri}; use reqwest::{header, StatusCode}; @@ -233,6 +234,7 @@ async fn test_h2_to_h1_upload() { assert_eq!(body, payload); } +#[cfg(unix)] #[tokio::test] async fn test_simple_proxy_uds() { init(); @@ -262,6 +264,7 @@ async fn test_simple_proxy_uds() { assert_eq!(body.as_ref(), b"Hello World!\n"); } +#[cfg(unix)] #[tokio::test] async fn test_simple_proxy_uds_peer() { init(); diff --git a/pingora-proxy/tests/utils/server_utils.rs b/pingora-proxy/tests/utils/server_utils.rs index 4f03f21..7db2622 100644 --- a/pingora-proxy/tests/utils/server_utils.rs +++ b/pingora-proxy/tests/utils/server_utils.rs @@ -279,6 +279,7 @@ impl ProxyHttp for ExampleProxyHttp { _ctx: &mut Self::CTX, ) -> Result> { let req = session.req_header(); + #[cfg(unix)] if req.headers.contains_key("x-uds-peer") { return Ok(Box::new(HttpPeer::new_uds( "/tmp/nginx-test.sock", diff --git a/pingora/Cargo.toml b/pingora/Cargo.toml index 7f5e101..b81141a 100644 --- a/pingora/Cargo.toml +++ b/pingora/Cargo.toml @@ -35,9 +35,7 @@ tokio = { workspace = true, features = ["rt-multi-thread", "signal"] } matches = "0.1" env_logger = "0.9" reqwest = { version = "0.11", features = ["rustls"], default-features = false } -hyperlocal = "0.8" hyper = "0.14" -jemallocator = "0.5" async-trait = { workspace = true } http = { workspace = true } log = { workspace = true } @@ -46,6 +44,10 @@ once_cell = { workspace = true } bytes = { workspace = true } regex = "1" +[target.'cfg(unix)'.dev-dependencies] +hyperlocal = "0.8" +jemallocator = "0.5" + [features] default = ["openssl"] openssl = [