Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONNECT tunneling example #1759

Closed
guskovd opened this issue Feb 3, 2019 · 2 comments
Closed

CONNECT tunneling example #1759

guskovd opened this issue Feb 3, 2019 · 2 comments
Labels
A-client Area: client. A-docs Area: documentation. E-easy Effort: easy. A task that would be a great starting point for a new contributor.

Comments

@guskovd
Copy link

guskovd commented Feb 3, 2019

After reading https://medium.com/@mlowicki/http-s-proxy-in-golang-in-less-than-100-lines-of-code-6a51c2f2c38c, the idea was born to write a proxy server on rust.

In https://github.com/hyperium/hyper/blob/master/examples/README.md is written that the example https://github.com/hyperium/hyper/blob/master/examples/upgrades.rs can help.

But I do not really understand how this can be done. I think it would be great to write an example of how to redirect CONNECT requests.

@seanmonstar seanmonstar added A-client Area: client. E-easy Effort: easy. A task that would be a great starting point for a new contributor. A-docs Area: documentation. labels Feb 11, 2019
@schlamar
Copy link

Basically you should mix server + client example into one async request.

On a CONNECT server request, you create a client CONNECT request to the remote proxy. If that suceeds (OK in client response), you send OK in the server response. Then you upgrade server request and client response to get both raw connections. Then you pipe everything through in both directions (here is an example for that: https://github.com/tokio-rs/tokio/blob/599955f/tokio/examples/proxy.rs#L68).

This could get messy with futures, though.

@seanmonstar
Copy link
Member

There's now an examples/http_proxy.rs file in master!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-client Area: client. A-docs Area: documentation. E-easy Effort: easy. A task that would be a great starting point for a new contributor.
Projects
None yet
Development

No branches or pull requests

3 participants