gitdataai/lib/config/ssh.rs
2026-05-30 01:38:40 +08:00

39 lines
1.2 KiB
Rust

use crate::AppConfig;
impl AppConfig {
pub fn ssh_domain(&self) -> anyhow::Result<String> {
if let Some(ssh_domain) = self.env.get("APP_SSH_DOMAIN") {
return Ok(ssh_domain.to_string());
}
let main_domain = self.main_domain()?;
if let Some(stripped) = main_domain.strip_prefix("https://") {
Ok(stripped.to_string())
} else if let Some(stripped) = main_domain.strip_prefix("http://") {
Ok(stripped.to_string())
} else {
Ok(main_domain)
}
}
pub fn ssh_port(&self) -> anyhow::Result<u16> {
if let Some(ssh_port) = self.env.get("APP_SSH_PORT") {
return Ok(ssh_port.parse::<u16>()?);
}
Ok(8022)
}
pub fn ssh_server_private_key_file(&self) -> anyhow::Result<String> {
if let Some(path) = self.env.get("APP_SSH_SERVER_PRIVATE_KEY_FILE") {
return Ok(path.to_string());
}
Ok("".to_string())
}
pub fn ssh_server_public_key_file(&self) -> anyhow::Result<String> {
if let Some(path) = self.env.get("APP_SSH_SERVER_PUBLIC_KEY_FILE") {
return Ok(path.to_string());
}
Ok("".to_string())
}
}