add podman detection

This commit is contained in:
monosans
2026-03-13 13:27:04 +03:00
parent 61ece037e5
commit bf18fd4441
4 changed files with 10 additions and 7 deletions
+2 -2
View File
@@ -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<raw_config::SourceConfig> for Source {
async fn get_output_path(
raw_config: &raw_config::RawConfig,
) -> crate::Result<PathBuf> {
let output_path = if is_docker().await {
let output_path = if is_container().await {
"./out".into()
} else {
raw_config.output.path.clone()
+2 -2
View File
@@ -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(),
+2 -2
View File
@@ -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()
+4 -1
View File
@@ -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<bool> =
@@ -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
}