1#[cfg(target_os = "macos")]
2mod macos_cfnetwork;
3
4#[cfg(target_os = "windows")]
5mod windows_winhttp;
6
7#[cfg(target_os = "linux")]
8mod linux_desktop;
9
10#[cfg(target_os = "macos")]
11pub use macos_cfnetwork::*;
12
13#[cfg(target_os = "windows")]
14pub use windows_winhttp::*;
15
16#[cfg(target_os = "linux")]
17pub use linux_desktop::*;
18
19#[derive(Debug, Clone)]
20pub struct Auth {
21 pub user: String,
22 pub password: Option<String>,
23}
24
25#[derive(Debug, Default, Clone)]
26pub struct Proxy {
27 pub host: String,
28 pub port: u16,
29 pub auth: Option<Auth>,
30 pub enabled: bool,
31}
32
33#[derive(Debug, Default, Clone)]
34pub struct Proxies {
35 pub http_proxy: Option<Proxy>,
36 pub https_proxy: Option<Proxy>,
37 pub socks_proxy: Option<Proxy>,
38 pub exclude_simple_host_names: bool,
39}
40
41#[derive(Debug, Clone)]
42pub struct Scope {
43 pub interface: String,
44 pub proxies: Proxies,
45 pub exceptions: Vec<String>,
46}
47
48#[derive(Debug, Clone)]
49pub struct ProxyConfig {
50 pub proxies: Proxies,
51 pub scopes: Vec<Scope>,
52}
53
54pub trait ProxyConfigProvider: Clone {
55 fn try_get() -> color_eyre::Result<Self>;
56}
57
58#[cfg(test)]
59mod test {
60 use crate::{ProxyConfig, ProxyConfigProvider};
61
62 #[test]
63 fn test_proxy_config() -> color_eyre::Result<()> {
64 color_eyre::install()?;
65 let proxy_config = ProxyConfig::try_get().unwrap();
66 println!("{:#?}", proxy_config);
67 Ok(())
68 }
69}