MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / edge_tunnel_addr

Function edge_tunnel_addr

crates/openshell-cli/src/tls.rs:319–339  ·  view source on GitHub ↗
(server: &str, token: &str)

Source from the content-addressed store, hash-verified

317static EDGE_TUNNEL_ADDRS: OnceLock<Mutex<HashMap<(String, String), SocketAddr>>> = OnceLock::new();
318
319async fn edge_tunnel_addr(server: &str, token: &str) -> Result<SocketAddr> {
320 let key = (server.to_string(), token.to_string());
321 let registry = EDGE_TUNNEL_ADDRS.get_or_init(|| Mutex::new(HashMap::new()));
322
323 {
324 let addrs = registry.lock().await;
325 if let Some(addr) = addrs.get(&key).copied() {
326 return Ok(addr);
327 }
328 }
329
330 let proxy = crate::edge_tunnel::start_tunnel_proxy(server, token).await?;
331 debug!(
332 local_addr = %proxy.local_addr,
333 server,
334 "edge tunnel proxy started, routing gRPC through local proxy"
335 );
336
337 let mut addrs = registry.lock().await;
338 Ok(*addrs.entry(key).or_insert(proxy.local_addr))
339}
340
341pub async fn build_channel(server: &str, tls: &TlsOptions) -> Result<Channel> {
342 if server.starts_with("http://") {

Callers 1

build_channelFunction · 0.85

Calls 2

start_tunnel_proxyFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected