Skip to content

http or socks5 proxies support #1206

Answered by cxw620
cxw620 asked this question in Q&A
Dec 20, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

The following example works!
I have marked all the places that can be modified.

    use hyper::client::{Client, HttpConnector};
    use hyper::Uri;
    use hyper_socks2::SocksConnector;
    use hyper_openssl::HttpsConnector;
    use openssl::ssl::{SslMethod, SslConnector};
    use tonic::metadata::{AsciiMetadataValue, MetadataValue};
    // ......
    // here is your socks5 proxy addr
    // must be like "socks5://host:port", scheme is required by HttpConnector
    let socks5_addr = "socks5://10.10.2.1:10003";
    let mut connector = HttpConnector::new();
    // "enforce_http(false)" is necessary, without it compiler will not complain but it actually will panic :)
    connector.enforce_http(

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@cxw620
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by cxw620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants