Struct wmproxy::ProxyConfig
source · pub struct ProxyConfig { /* private fields */ }
Expand description
代理类, 一个代理类启动一种类型的代理
Implementations§
source§impl ProxyConfig
impl ProxyConfig
sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Examples found in repository?
examples/proxy.rs (line 117)
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
async fn main() {
let src = "wmproxy is good";
let first = &src[..7];
let second = &src[3..8];
let end = &src[8..];
assert!(wmproxy::Helper::is_match("/wmproxy/is_good", "*wmproxy*good"));
let addr = "localhost:123".parse::<SocketAddr>();
println!("addr = {:?}", addr);
let addr: SocketAddr = "127.0.0.1:0".parse().unwrap();
let username = "wmproxy".to_string();
let password = "wmproxy".to_string();
let proxy = ProxyConfig::builder()
.bind(addr)
.username(Some(username.clone()))
.password(Some(password.clone()))
.into_value()
.unwrap();
let (server_addr, _sender) = run_proxy(proxy)
.await
.unwrap();
let proxy = ProxyConfig::builder()
.bind(addr)
.username(Some(username.clone()))
.password(Some(password.clone()))
.server(Some(format!("{}", server_addr)))
.into_value()
.unwrap();
let (addr, _sender) = run_proxy(proxy)
.await
.unwrap();
// test_proxy(addr, HTTP_URL, "http", None, true).await;
// test_proxy(addr, HTTPS_URL, "http", None, true).await;
// test_proxy(addr, HTTP_URL, "socks5", None, true).await;
let auth = Some((username, password));
test_proxy(addr, HTTP_URL, "http", auth.clone(), false).await;
test_proxy(addr, HTTPS_URL, "http", auth.clone(), false).await;
test_proxy(addr, HTTP_URL, "socks5", auth.clone(), false).await;
}
sourcepub async fn get_map_tls_accept(&self) -> ProxyResult<TlsAcceptor>
pub async fn get_map_tls_accept(&self) -> ProxyResult<TlsAcceptor>
获取服务端https的证书信息
sourcepub async fn get_tls_accept(&self) -> ProxyResult<TlsAcceptor>
pub async fn get_tls_accept(&self) -> ProxyResult<TlsAcceptor>
获取服务端https的证书信息
sourcepub async fn get_tls_request(&self) -> ProxyResult<Arc<ClientConfig>>
pub async fn get_tls_request(&self) -> ProxyResult<Arc<ClientConfig>>
获取客户端https的Config配置
pub async fn bind( &self ) -> ProxyResult<(Option<TlsAcceptor>, Option<Arc<ClientConfig>>, Option<TcpListener>, Option<TcpListener>, Option<CenterClient>)>
pub async fn bind_map( &self ) -> ProxyResult<(Option<TcpListener>, Option<TcpListener>, Option<TcpListener>, Option<TcpListener>, Option<TlsAcceptor>)>
Trait Implementations§
source§impl Clone for ProxyConfig
impl Clone for ProxyConfig
source§fn clone(&self) -> ProxyConfig
fn clone(&self) -> ProxyConfig
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ProxyConfig
impl Debug for ProxyConfig
source§impl Default for ProxyConfig
impl Default for ProxyConfig
source§impl<'de> Deserialize<'de> for ProxyConfig
impl<'de> Deserialize<'de> for ProxyConfig
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for ProxyConfig
impl Send for ProxyConfig
impl Sync for ProxyConfig
impl Unpin for ProxyConfig
impl UnwindSafe for ProxyConfig
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more