11// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22// SPDX-License-Identifier: Apache-2.0
33
4- //! Sandbox-local [`BoundaryPortForward `] implementation.
4+ //! Sandbox-local [`BoundaryLoopbackConnector `] implementation.
55
66use async_trait:: async_trait;
77use openshell_isolation_interface:: contract:: {
8- BackendError , BoundaryDuplexStream , BoundaryPortForward , LoopbackTarget ,
8+ BackendError , BoundaryDuplexStream , BoundaryLoopbackConnector , LoopbackTarget ,
99} ;
1010use std:: collections:: HashMap ;
1111use std:: sync:: atomic:: { AtomicU8 , Ordering } ;
@@ -168,19 +168,19 @@ impl RegisteredProcessGroup {
168168}
169169
170170/// Loopback port-forward owned by the sandbox process.
171- pub struct LocalPortForward {
171+ pub struct LocalLoopbackConnector {
172172 runtime : Option < Arc < BoundaryRuntimeState > > ,
173173}
174174
175- impl LocalPortForward {
175+ impl LocalLoopbackConnector {
176176 #[ must_use]
177177 pub fn new ( runtime : Option < Arc < BoundaryRuntimeState > > ) -> Self {
178178 Self { runtime }
179179 }
180180}
181181
182182#[ async_trait]
183- impl BoundaryPortForward for LocalPortForward {
183+ impl BoundaryLoopbackConnector for LocalLoopbackConnector {
184184 async fn connect ( & self , target : LoopbackTarget ) -> Result < BoundaryDuplexStream , BackendError > {
185185 if let Some ( runtime) = & self . runtime {
186186 runtime. ensure_active ( ) ?;
@@ -205,7 +205,7 @@ mod tests {
205205 /// Stands in for the SSH server's port-forward path: connect through the
206206 /// interface, write, and read the echo.
207207 #[ tokio:: test]
208- async fn port_forward_connects_and_round_trips ( ) {
208+ async fn loopback_connector_connects_and_round_trips ( ) {
209209 let listener = tokio:: net:: TcpListener :: bind ( "127.0.0.1:0" ) . await . unwrap ( ) ;
210210 let addr = listener. local_addr ( ) . unwrap ( ) ;
211211 tokio:: spawn ( async move {
@@ -215,7 +215,7 @@ mod tests {
215215 sock. write_all ( & buf) . await . unwrap ( ) ;
216216 } ) ;
217217
218- let pf = LocalPortForward :: new ( None ) ;
218+ let pf = LocalLoopbackConnector :: new ( None ) ;
219219 let target =
220220 LoopbackTarget :: new ( Ipv4Addr :: LOCALHOST . into ( ) , addr. port ( ) ) . expect ( "loopback target" ) ;
221221 let mut conn = pf. connect ( target) . await . expect ( "connect through interface" ) ;
@@ -228,24 +228,24 @@ mod tests {
228228 /// Drive the port-forward interface through a generic `&dyn` consumer, proving a
229229 /// kernel-separated backend (tunneling into a guest) would use the same call.
230230 #[ tokio:: test]
231- async fn port_forward_is_driven_via_dyn ( ) {
232- async fn forward_one ( pf : & dyn BoundaryPortForward , target : LoopbackTarget ) -> bool {
231+ async fn loopback_connector_is_driven_via_dyn ( ) {
232+ async fn forward_one ( pf : & dyn BoundaryLoopbackConnector , target : LoopbackTarget ) -> bool {
233233 pf. connect ( target) . await . is_ok ( )
234234 }
235235 let listener = tokio:: net:: TcpListener :: bind ( "127.0.0.1:0" ) . await . unwrap ( ) ;
236236 let addr = listener. local_addr ( ) . unwrap ( ) ;
237237 tokio:: spawn ( async move {
238238 let _ = listener. accept ( ) . await ;
239239 } ) ;
240- let pf = LocalPortForward :: new ( None ) ;
240+ let pf = LocalLoopbackConnector :: new ( None ) ;
241241 let target = LoopbackTarget :: new ( Ipv4Addr :: LOCALHOST . into ( ) , addr. port ( ) ) . unwrap ( ) ;
242242 assert ! ( forward_one( & pf, target) . await ) ;
243243 }
244244
245245 #[ tokio:: test]
246- async fn port_forward_rejects_after_boundary_end ( ) {
246+ async fn loopback_connector_rejects_after_boundary_end ( ) {
247247 let runtime = BoundaryRuntimeState :: new ( ) ;
248- let pf = LocalPortForward :: new ( Some ( runtime. clone ( ) ) ) ;
248+ let pf = LocalLoopbackConnector :: new ( Some ( runtime. clone ( ) ) ) ;
249249 runtime. deactivate ( ) ;
250250 let target = LoopbackTarget :: new ( Ipv4Addr :: LOCALHOST . into ( ) , 1 ) . unwrap ( ) ;
251251 assert ! ( matches!(
@@ -255,9 +255,9 @@ mod tests {
255255 }
256256
257257 #[ tokio:: test]
258- async fn failed_port_forward_keeps_boundary_active ( ) {
258+ async fn failed_loopback_connector_keeps_boundary_active ( ) {
259259 let runtime = BoundaryRuntimeState :: new ( ) ;
260- let pf = LocalPortForward :: new ( Some ( runtime. clone ( ) ) ) ;
260+ let pf = LocalLoopbackConnector :: new ( Some ( runtime. clone ( ) ) ) ;
261261 // Port zero is never a connectable TCP destination. Reserving an ephemeral
262262 // port and dropping its listener races other parallel tests that may bind it.
263263 let target = LoopbackTarget :: new ( Ipv4Addr :: LOCALHOST . into ( ) , 0 ) . unwrap ( ) ;
0 commit comments