1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::connectors::Client;
use hyper::Uri;
pub use hyper_proxy as https;
pub use hyper_socks2 as socks;
use socks::Auth;
#[derive(Debug, Clone)]
pub enum Proxy {
Https(https::Proxy),
Socks {
uri: Uri,
auth: Option<Auth>,
},
}
impl Proxy {
pub const fn https(proxy: https::Proxy) -> Self {
Self::Https(proxy)
}
pub const fn socks(uri: Uri, auth: Option<Auth>) -> Self {
Self::Socks { uri, auth }
}
}
impl From<https::Proxy> for Proxy {
fn from(proxy: https::Proxy) -> Self {
Self::https(proxy)
}
}
impl From<Proxy> for Client {
fn from(proxy: Proxy) -> Self {
match proxy {
Proxy::Https(https) => Self::https_proxy(https),
Proxy::Socks { uri, auth } => Self::socks_proxy(uri, auth),
}
}
}