aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrew Hauck <[email protected]>2024-09-27 15:37:47 -0700
committerYuchen Wu <[email protected]>2024-10-11 15:40:59 -0700
commitf90045055529aaa3f3847c7cac60af2b251b9ac6 (patch)
tree52a045ffd8054a6a8e8654614ed92d4b6241d42e
parent2a62acd60b2c24c82ca1119f62a27c08508bf730 (diff)
downloadpingora-f90045055529aaa3f3847c7cac60af2b251b9ac6.tar.gz
pingora-f90045055529aaa3f3847c7cac60af2b251b9ac6.zip
Add windows compatibility for get_original_dest()
-rw-r--r--.bleep2
-rw-r--r--pingora-core/src/protocols/digest.rs13
-rw-r--r--pingora-core/src/protocols/l4/ext.rs7
3 files changed, 20 insertions, 2 deletions
diff --git a/.bleep b/.bleep
index 1ac3b4f..4611476 100644
--- a/.bleep
+++ b/.bleep
@@ -1 +1 @@
-73cbdf49b1e1279ebba51525cad01952d4dc04d2 \ No newline at end of file
+9d8254e966aca99eeb6623f2bcf5fc93facbb05a \ No newline at end of file
diff --git a/pingora-core/src/protocols/digest.rs b/pingora-core/src/protocols/digest.rs
index 9e23741..19dc78d 100644
--- a/pingora-core/src/protocols/digest.rs
+++ b/pingora-core/src/protocols/digest.rs
@@ -162,6 +162,7 @@ impl SocketDigest {
}
}
+ #[cfg(unix)]
pub fn original_dst(&self) -> Option<&SocketAddr> {
self.original_dst
.get_or_init(|| {
@@ -172,6 +173,18 @@ impl SocketDigest {
})
.as_ref()
}
+
+ #[cfg(windows)]
+ pub fn original_dst(&self) -> Option<&SocketAddr> {
+ self.original_dst
+ .get_or_init(|| {
+ get_original_dest(self.raw_sock)
+ .ok()
+ .flatten()
+ .map(SocketAddr::Inet)
+ })
+ .as_ref()
+ }
}
/// The interface to return timing information
diff --git a/pingora-core/src/protocols/l4/ext.rs b/pingora-core/src/protocols/l4/ext.rs
index fae93f7..b687cc4 100644
--- a/pingora-core/src/protocols/l4/ext.rs
+++ b/pingora-core/src/protocols/l4/ext.rs
@@ -413,11 +413,16 @@ pub fn get_original_dest(fd: RawFd) -> Result<Option<SocketAddr>> {
.map(Some)
}
-#[cfg(not(target_os = "linux"))]
+#[cfg(all(unix, not(target_os = "linux")))]
pub fn get_original_dest(_fd: RawFd) -> Result<Option<SocketAddr>> {
Ok(None)
}
+#[cfg(windows)]
+pub fn get_original_dest(_sock: RawSocket) -> Result<Option<SocketAddr>> {
+ Ok(None)
+}
+
/// connect() to the given address while optionally binding to the specific source address and port range.
///
/// The `set_socket` callback can be used to tune the socket before `connect()` is called.