Skip to content
\n

It's really complex and troublesome, I think. However, this is the only way I have figured out, for I'm new in rust, as well as tonic. I hope someone can make some suggestions for optimizing it...
\nBTW, will it be possible for tonic to support adding socks5 proxy directly like the following? It will really save much time.

\n
let channel = Channel::from_static(\"http://[::1]:50051\").with_proxy_socks5(\"socks5://127.0.0.1:8888\").connect().await.unwrap();
","upvoteCount":1,"url":"https://github.com/hyperium/tonic/discussions/1206#discussioncomment-4652443"}}}
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: 3 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
Comment options

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