#[derive(Clone, Debug)]
pub struct ProxyConfiguration {
pub proxy_allowed: bool,
pub https_proxy_set: bool,
pub http_proxy_set: bool,
}
impl ProxyConfiguration {
pub fn from_env(proxy_allowed: bool) -> Self {
let (https_proxy_set, http_proxy_set) = if proxy_allowed {
(
std::env::var("HTTPS_PROXY")
.or_else(|_| std::env::var("https_proxy"))
.is_ok(),
std::env::var("HTTP_PROXY")
.or_else(|_| std::env::var("http_proxy"))
.is_ok(),
)
} else {
(false, false)
};
Self {
proxy_allowed,
https_proxy_set,
http_proxy_set,
}
}
}