facebook / proxygen

A collection of C++ HTTP libraries including an easy to use HTTP server.
Other
8.03k stars 1.47k forks source link

SessionPooling #459

Closed SteveSelva closed 7 months ago

SteveSelva commented 9 months ago

I am creating a HTTPS Forward Proxy Server using the example given in Proxygen's proxygen-proxy Project. I have modified some changes to make it work as I want.

The code flow of the HTTPS Forward Proxy Server is mentioned below:

HTTPServer is listening for connections on port X. AcceptorFactory is initialized with a SessionPool which is common for the whole proxy. AcceptorFactory creates HTTPServerAcceptor according to number of threads present in PC. While creating instances of HTTPServerAcceptor, SessionPool object is being shared as pointers. When connection is accepted it is processed in HTTPServerAcceptor. HTTPServerAcceptor establishes the downstream connection. While creating a downstream session, it asks for a RequestHandler. HTTPServerAcceptor creates a RequestHandler with SessionPool's pointer and sends it to Downstream Session. Then the Request in sent to RequestHandler. RequestHandler checks the SessionPool whether already a session is available for the Upstream session, if present uses the session, if not it establishes an upstream connection and creates an Upstream Session and the created UpstreamSession is stored in that SessionPool. In this flow, I implemented SessionPool at AcceptorFactory and sending that SessionPool's pointer to HTTPServerAcceptor and RequestHandler thereby a common SessionPool is utilized by the whole proxy making it efficient.

Is this approach correct?

Note: ProxyServer is working in TLS 1.3 HTTP/2 Protocol as Forward Proxy.