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

Function default_tls_dir

crates/openshell-cli/src/tls.rs:125–147  ·  view source on GitHub ↗

Fallback TLS directory resolution from a server URL. Used when no gateway name is set (e.g., `SshProxy` which receives a raw URL).

(server: &str)

Source from the content-addressed store, hash-verified

123///
124/// Used when no gateway name is set (e.g., `SshProxy` which receives a raw URL).
125fn default_tls_dir(server: &str) -> Option<PathBuf> {
126 let mut name = std::env::var("OPENSHELL_GATEWAY")
127 .ok()
128 .filter(|value| !value.trim().is_empty());
129
130 if name.is_none()
131 && let Ok(uri) = server.parse::<hyper::Uri>()
132 && let Some(host) = uri.host()
133 {
134 name = Some(
135 if host == "127.0.0.1" || host.eq_ignore_ascii_case("localhost") {
136 "openshell".to_string()
137 } else {
138 host.to_string()
139 },
140 );
141 }
142
143 let name = name.unwrap_or_else(|| "openshell".to_string());
144 let safe_name = sanitize_name(&name);
145 let base = xdg_config_dir().ok()?.join("openshell").join("gateways");
146 Some(base.join(safe_name).join("mtls"))
147}
148
149fn sanitize_name(value: &str) -> String {
150 value

Callers 2

with_default_pathsMethod · 0.85
require_tls_materialsFunction · 0.85

Calls 3

sanitize_nameFunction · 0.85
xdg_config_dirFunction · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected