Struct wmproxy::Builder

source ·
pub struct Builder { /* private fields */ }

Implementations§

source§

impl Builder

source

pub fn new() -> Builder

source

pub fn flag(self, flag: Flag) -> Builder

source

pub fn add_flag(self, flag: Flag) -> Builder

source

pub fn bind(self, addr: SocketAddr) -> Builder

Examples found in repository?
examples/proxy.rs (line 118)
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;
}
source

pub fn center_addr(self, addr: SocketAddr) -> Builder

source

pub fn server(self, addr: Option<String>) -> Builder

Examples found in repository?
examples/proxy.rs (line 132)
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;
}
source

pub fn ts(self, is_tls: bool) -> Builder

source

pub fn tc(self, is_tls: bool) -> Builder

source

pub fn cert(self, cert: Option<String>) -> Builder

source

pub fn key(self, key: Option<String>) -> Builder

source

pub fn domain(self, domain: Option<String>) -> Builder

source

pub fn username(self, username: Option<String>) -> Builder

Examples found in repository?
examples/proxy.rs (line 119)
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;
}
source

pub fn password(self, password: Option<String>) -> Builder

Examples found in repository?
examples/proxy.rs (line 120)
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;
}
source

pub fn udp_bind(self, udp_bind: Option<IpAddr>) -> Builder

source

pub fn map_http_bind(self, map_http_bind: Option<SocketAddr>) -> Builder

source

pub fn map_https_bind(self, map_https_bind: Option<SocketAddr>) -> Builder

source

pub fn map_tcp_bind(self, map_tcp_bind: Option<SocketAddr>) -> Builder

source

pub fn map_proxy_bind(self, map_proxy_bind: Option<SocketAddr>) -> Builder

source

pub fn mapping(self, mapping: MappingConfig) -> Builder

source

pub fn into_value(self) -> ProxyResult<ProxyConfig>

Examples found in repository?
examples/proxy.rs (line 121)
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;
}

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> UnsafeAny for T
where T: Any,