Skip to content

Commit bf18fd4

Browse files
committed
add podman detection
1 parent 61ece03 commit bf18fd4

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
use color_eyre::eyre::WrapErr as _;
99

1010
use crate::{
11-
HashMap, http::BasicAuth, proxy::ProxyType, raw_config, utils::is_docker,
11+
HashMap, http::BasicAuth, proxy::ProxyType, raw_config, utils::is_container,
1212
};
1313

1414
pub const APP_DIRECTORY_NAME: &str = "proxy_scraper_checker";
@@ -84,7 +84,7 @@ impl From<raw_config::SourceConfig> for Source {
8484
async fn get_output_path(
8585
raw_config: &raw_config::RawConfig,
8686
) -> crate::Result<PathBuf> {
87-
let output_path = if is_docker().await {
87+
let output_path = if is_container().await {
8888
"./out".into()
8989
} else {
9090
raw_config.output.path.clone()

src/ipdb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tokio::io::AsyncWriteExt as _;
55

66
#[cfg(feature = "tui")]
77
use crate::event::{AppEvent, Event};
8-
use crate::{fs::get_cache_path, utils::is_docker};
8+
use crate::{fs::get_cache_path, utils::is_container};
99

1010
#[derive(Clone, Copy)]
1111
pub enum DbType {
@@ -61,7 +61,7 @@ impl DbType {
6161
)
6262
.await?;
6363

64-
if is_docker().await {
64+
if is_container().await {
6565
tracing::info!(
6666
"Downloaded {} database to Docker volume ({} in container)",
6767
self.name(),

src/output.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
config::Config,
1717
ipdb,
1818
proxy::{Proxy, ProxyType},
19-
utils::is_docker,
19+
utils::is_container,
2020
};
2121

2222
fn compare_timeout(a: &Proxy, b: &Proxy) -> Ordering {
@@ -287,7 +287,7 @@ pub async fn save_proxies(
287287
let path = tokio::fs::canonicalize(&config.output.path)
288288
.await
289289
.unwrap_or_else(move |_| config.output.path.clone());
290-
if is_docker().await {
290+
if is_container().await {
291291
tracing::info!(
292292
"Proxies have been saved to ./out ({} in container)",
293293
path.display()

src/utils.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn pretty_error(e: &crate::Error) -> compact_str::CompactString {
3030
e.chain().join(" \u{2192} ")
3131
}
3232

33-
pub async fn is_docker() -> bool {
33+
pub async fn is_container() -> bool {
3434
#[cfg(target_os = "linux")]
3535
{
3636
static CACHE: tokio::sync::OnceCell<bool> =
@@ -39,6 +39,9 @@ pub async fn is_docker() -> bool {
3939
*CACHE
4040
.get_or_init(async || {
4141
tokio::fs::try_exists("/.dockerenv").await.unwrap_or(false)
42+
|| tokio::fs::try_exists("/run/.containerenv")
43+
.await
44+
.unwrap_or(false)
4245
})
4346
.await
4447
}

0 commit comments

Comments
 (0)