diff --git a/src/config.rs b/src/config.rs index 0f32cbe..7c60488 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,7 @@ use std::{ use color_eyre::eyre::WrapErr as _; use crate::{ - HashMap, http::BasicAuth, proxy::ProxyType, raw_config, utils::is_docker, + HashMap, http::BasicAuth, proxy::ProxyType, raw_config, utils::is_container, }; pub const APP_DIRECTORY_NAME: &str = "proxy_scraper_checker"; @@ -84,7 +84,7 @@ impl From for Source { async fn get_output_path( raw_config: &raw_config::RawConfig, ) -> crate::Result { - let output_path = if is_docker().await { + let output_path = if is_container().await { "./out".into() } else { raw_config.output.path.clone() diff --git a/src/ipdb.rs b/src/ipdb.rs index cef1b16..d2e2383 100644 --- a/src/ipdb.rs +++ b/src/ipdb.rs @@ -5,7 +5,7 @@ use tokio::io::AsyncWriteExt as _; #[cfg(feature = "tui")] use crate::event::{AppEvent, Event}; -use crate::{fs::get_cache_path, utils::is_docker}; +use crate::{fs::get_cache_path, utils::is_container}; #[derive(Clone, Copy)] pub enum DbType { @@ -61,7 +61,7 @@ impl DbType { ) .await?; - if is_docker().await { + if is_container().await { tracing::info!( "Downloaded {} database to Docker volume ({} in container)", self.name(), diff --git a/src/output.rs b/src/output.rs index d35edc9..bf3702c 100644 --- a/src/output.rs +++ b/src/output.rs @@ -16,7 +16,7 @@ use crate::{ config::Config, ipdb, proxy::{Proxy, ProxyType}, - utils::is_docker, + utils::is_container, }; fn compare_timeout(a: &Proxy, b: &Proxy) -> Ordering { @@ -287,7 +287,7 @@ pub async fn save_proxies( let path = tokio::fs::canonicalize(&config.output.path) .await .unwrap_or_else(move |_| config.output.path.clone()); - if is_docker().await { + if is_container().await { tracing::info!( "Proxies have been saved to ./out ({} in container)", path.display() diff --git a/src/utils.rs b/src/utils.rs index 1b0780d..9e925c1 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -30,7 +30,7 @@ pub fn pretty_error(e: &crate::Error) -> compact_str::CompactString { e.chain().join(" \u{2192} ") } -pub async fn is_docker() -> bool { +pub async fn is_container() -> bool { #[cfg(target_os = "linux")] { static CACHE: tokio::sync::OnceCell = @@ -39,6 +39,9 @@ pub async fn is_docker() -> bool { *CACHE .get_or_init(async || { tokio::fs::try_exists("/.dockerenv").await.unwrap_or(false) + || tokio::fs::try_exists("/run/.containerenv") + .await + .unwrap_or(false) }) .await }