diff options
author | Alex Severin <[email protected]> | 2024-04-26 21:05:38 +0000 |
---|---|---|
committer | Gideon Tong <[email protected]> | 2024-06-14 16:00:03 -0700 |
commit | 20cac2e6730580d83fd603867d67f4ac8987e329 (patch) | |
tree | 50478a79d5c649d4611b60128f2449f2ee9745e0 | |
parent | 1d32d069cde2d4a8ca3f0b3b31035982b310f543 (diff) | |
download | pingora-20cac2e6730580d83fd603867d67f4ac8987e329.tar.gz pingora-20cac2e6730580d83fd603867d67f4ac8987e329.zip |
expose new_uds err
-rw-r--r-- | .bleep | 2 | ||||
-rw-r--r-- | pingora-core/src/upstreams/peer.rs | 13 | ||||
-rw-r--r-- | pingora-proxy/tests/utils/server_utils.rs | 2 |
3 files changed, 11 insertions, 6 deletions
@@ -1 +1 @@ -3c6f56ba2c6cd48aa5f4edd442090e95739d15fc
\ No newline at end of file +32b73315dbc9aa07ca121a5fde8fc58dde5b9e1b diff --git a/pingora-core/src/upstreams/peer.rs b/pingora-core/src/upstreams/peer.rs index 21f737b..7c0277c 100644 --- a/pingora-core/src/upstreams/peer.rs +++ b/pingora-core/src/upstreams/peer.rs @@ -15,7 +15,10 @@ //! Defines where to connect to and how to connect to a remote server use ahash::AHasher; -use pingora_error::{ErrorType::InternalError, OrErr, Result}; +use pingora_error::{ + ErrorType::{InternalError, SocketError}, + OrErr, Result, +}; use std::collections::BTreeMap; use std::fmt::{Display, Formatter, Result as FmtResult}; use std::hash::{Hash, Hasher}; @@ -431,9 +434,11 @@ impl HttpPeer { } /// Create a new [`HttpPeer`] with the given path to Unix domain socket and TLS settings. - pub fn new_uds(path: &str, tls: bool, sni: String) -> Self { - let addr = SocketAddr::Unix(UnixSocketAddr::from_pathname(Path::new(path)).unwrap()); //TODO: handle error - Self::new_from_sockaddr(addr, tls, sni) + pub fn new_uds(path: &str, tls: bool, sni: String) -> Result<Self> { + let addr = SocketAddr::Unix( + UnixSocketAddr::from_pathname(Path::new(path)).or_err(SocketError, "invalid path")?, + ); + Ok(Self::new_from_sockaddr(addr, tls, sni)) } /// Create a new [`HttpPeer`] that uses a proxy to connect to the upstream IP and port diff --git a/pingora-proxy/tests/utils/server_utils.rs b/pingora-proxy/tests/utils/server_utils.rs index 1397e2c..84b2c12 100644 --- a/pingora-proxy/tests/utils/server_utils.rs +++ b/pingora-proxy/tests/utils/server_utils.rs @@ -264,7 +264,7 @@ impl ProxyHttp for ExampleProxyHttp { "/tmp/nginx-test.sock", false, "".to_string(), - ))); + )?)); } let port = req .headers |