about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
Diffstat (limited to 'tvix')
-rw-r--r--tvix/store/src/listener/mod.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/tvix/store/src/listener/mod.rs b/tvix/store/src/listener/mod.rs
index 3a44a0511cb8..ed1220803562 100644
--- a/tvix/store/src/listener/mod.rs
+++ b/tvix/store/src/listener/mod.rs
@@ -9,7 +9,7 @@ use futures::Stream;
 use pin_project_lite::pin_project;
 use tokio::io::{AsyncRead, AsyncWrite};
 use tokio_listener::{Listener, ListenerAddress};
-use tonic::transport::server::Connected;
+use tonic::transport::server::{Connected, TcpConnectInfo, UdsConnectInfo};
 
 /// A wrapper around a [Listener] which implements the [Stream] trait.
 /// Mainly used to bridge [tokio_listener] with [tonic].
@@ -72,11 +72,27 @@ impl DerefMut for Connection {
     }
 }
 
+#[derive(Clone)]
+pub enum ListenerConnectInfo {
+    TCP(TcpConnectInfo),
+    Unix(UdsConnectInfo),
+    Stdio,
+    Other,
+}
+
 impl Connected for Connection {
-    type ConnectInfo = ();
+    type ConnectInfo = ListenerConnectInfo;
 
     fn connect_info(&self) -> Self::ConnectInfo {
-        ()
+        if let Some(tcp_stream) = self.try_borrow_tcp() {
+            ListenerConnectInfo::TCP(tcp_stream.connect_info())
+        } else if let Some(unix_stream) = self.try_borrow_unix() {
+            ListenerConnectInfo::Unix(unix_stream.connect_info())
+        } else if let Some(_) = self.try_borrow_stdio() {
+            ListenerConnectInfo::Stdio
+        } else {
+            ListenerConnectInfo::Other
+        }
     }
 }