payjoin / ohttp-relay

Oblivious HTTP relay resource in Rust
14 stars 6 forks source link

Example for establishing a full connection of ohttp #38

Open YKunDong opened 2 weeks ago

YKunDong commented 2 weeks ago

I am trying to implement the ohttp recently. Although there are project of relay, and project for client and server (https://github.com/martinthomson/ohttp), I find it difficult to make them work together.

Is it possible to show an example to establish a full connection of ohtttp, like, combining these two project?

Any suggestion or help will be appreciated.

DanGould commented 1 week ago

Hey @YKunDong thanks for your interest in OHTTP 🦸‍♂️ I agree, the resources on how to actually use OHTTP in practice are limited, and cloudflare's ohttp relay is the only implementation one I know of besides the ohttp-relay we maintain in this organization.

Please find a full example of an OHTTP client using this library to transmit its message over an ohttp relay to an ohttp gateway and finally target in this e2e test. There's a lot of other application code in there, but between e2e and this integration test suite you should be able to find what you're looking for.

I do think an actual dead-simple example is needed in the ohttp-relay crate. That would require someone write up the gateway and target servers inside an example, and call ohttp_relay to listen as a proxy in between. Let me know if you find what you're looking for in these tests.

YKunDong commented 1 week ago

Thanks for the material provided. Having the relay running, which listens on tcp://0.0.0.0:3000 in my test. I set the proxy as following, and the connection between client - relay - gateway is successfully established.

HTTPS_PROXY=http://127.0.0.1:3000 HTTP_PROXY=http://127.0.0.1:3000