ark0f / async-socks5

An async/.await SOCKS5 implementation
Apache License 2.0
80 stars 16 forks source link

How to combine async-socks5 with tungstenite? #37

Open Praying opened 2 years ago

Praying commented 2 years ago

I need a proxy on websocket with tungstenite, and I don't know how to implement it with async-socks5, do you have any experience or example?

Praying commented 2 years ago

tokio-tungstenite is also ok

ark0f commented 2 years ago

do you have any experience

I have not, but I can guess it should look like this:

let stream = TcpStream::connect("my-proxy-server.com:54321").await?;
async_socks5::connect(&mut stream, ("your-ws-server.com", 80), None).await?;
let (ws_stream, _) = tokio_tungstenite::client_async("ws://your-ws-server.com:80", stream).await?;
Praying commented 2 years ago

do you have any experience

I have not, but I can guess it should look like this:

let stream = TcpStream::connect("my-proxy-server.com:54321").await?;
async_socks5::connect(&mut stream, ("your-ws-server.com", 80), None).await?;
let (ws_stream, _) = tokio_tungstenite::client_async("ws://your-ws-server.com:80", stream).await?;

I have try it, didn't work