aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/proxy.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/modules/proxy.rs b/src/modules/proxy.rs
index 2d6b254..aecd775 100644
--- a/src/modules/proxy.rs
+++ b/src/modules/proxy.rs
@@ -40,6 +40,7 @@ struct Proxy {
#[derive(Debug)]
enum SocketAddrOrPath {
+ Host(String),
Ip(SocketAddr),
Unix(PathBuf),
}
@@ -65,6 +66,8 @@ impl<'de> Deserialize<'de> for SocketAddrOrPath {
let s = String::deserialize(deserializer)?;
if s.starts_with("/") {
Ok(Self::Unix(PathBuf::from_str(&s).map_err(|e| match e {})?))
+ } else if let Some(host) = s.strip_prefix("@") {
+ Ok(Self::Host(host.to_string()))
} else if let Some(port) = s.strip_prefix(":") {
Ok(Self::Ip(SocketAddr::V4(SocketAddrV4::new(
Ipv4Addr::LOCALHOST,
@@ -82,6 +85,7 @@ impl Display for SocketAddrOrPath {
match self {
SocketAddrOrPath::Ip(addr) => write!(f, "{addr}"),
SocketAddrOrPath::Unix(path) => write!(f, "unix:{}", path.to_string_lossy()),
+ SocketAddrOrPath::Host(host) => write!(f, "host:{host}"),
}
}
}
@@ -155,6 +159,15 @@ impl Node for Proxy {
)
.await?
}
+ SocketAddrOrPath::Host(host) => {
+ send_request(
+ TcpStream::connect(host)
+ .await
+ .map_err(|_| ServiceError::CantConnect)?,
+ request,
+ )
+ .await?
+ }
SocketAddrOrPath::Unix(path) => {
send_request(
UnixStream::connect(path)