aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlex Severin <[email protected]>2024-04-26 21:05:38 +0000
committerGideon Tong <[email protected]>2024-06-14 16:00:03 -0700
commit20cac2e6730580d83fd603867d67f4ac8987e329 (patch)
tree50478a79d5c649d4611b60128f2449f2ee9745e0
parent1d32d069cde2d4a8ca3f0b3b31035982b310f543 (diff)
downloadpingora-20cac2e6730580d83fd603867d67f4ac8987e329.tar.gz
pingora-20cac2e6730580d83fd603867d67f4ac8987e329.zip
expose new_uds err
-rw-r--r--.bleep2
-rw-r--r--pingora-core/src/upstreams/peer.rs13
-rw-r--r--pingora-proxy/tests/utils/server_utils.rs2
3 files changed, 11 insertions, 6 deletions
diff --git a/.bleep b/.bleep
index 398515b..0b4740d 100644
--- a/.bleep
+++ b/.bleep
@@ -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