cloudflare / pingora

A library for building fast, reliable and evolvable network services.
Apache License 2.0
20.35k stars 1.1k forks source link

Documentation for L4 API (TCP\UDP) #115

Closed realkarmakun closed 2 months ago

realkarmakun commented 4 months ago

It would be nice to have, since as far as I can see from the source code handling L4 requires more work (Don't see something like ProxyHttp and Peer trait but for TCP\UDP in the source)

realkarmakun commented 4 months ago

Also would it be possible to build custom L7 on top of TCP/UPD using pingora?

eaufavor commented 3 months ago

See the examples here for L4 and L7 proxies. https://github.com/cloudflare/pingora/blob/main/pingora/examples/server.rs

build custom L7 on top of TCP using pingora

Yes, pingora-proxy itself is built on top of these APIs. We don't have traits and better APIs because 1. the L4 proxy itself is pretty simple and 2. we are not sure of the use cases. So we don't want to build something without understanding the users.

Let us know if there is any proposal what the APIs should look like.

github-actions[bot] commented 3 months ago

This question has been stale for a week. It will be closed in an additional day if not updated.

realkarmakun commented 3 months ago

@eaufavor Sorry for taking so long

we are not sure of the use cases

I personally see one use case for implementing proxy with custom L7 protocol on top of pingora. Specifically Minecraft protocol (based on TCP). Minecraft server owners can benefit by using a native solution (Current solutions are fairly fast don't get me wrong). But it can be a good alternative. As for API, specifically for Minecraft case it would be nice to be able to intercept data inside the stream of packets, to be able to inject data or remove it.

I'm guessing this kind of API would require implementations of your own Peer (essentially socket address and perhaps a way to define custom attributes like in Http Peer but specific for end user's L7 definition). Ability to define your own L7 level phases, filters and so on. As I can see currently this would require modifying Pingora's code to add said implementations? Please correct me if I'm wrong.

Going further than Minecraft, it would be nice to have similar way to define your own implementation for UDP too for either other games or protocols.

github-actions[bot] commented 3 months ago

This question has been stale for a week. It will be closed in an additional day if not updated.

github-actions[bot] commented 3 months ago

This issue has been closed because it has been stalled with no activity.

Duvieusam commented 3 months ago

Hi, is there any plan to add documentation about TCP handling ?

I do have a use case for this as I want to replace a Haproxy that handles HTTP, HTTPS and TCP connections. Moreover the Haproxy does not hold the TLS certificates so the HTTPS connections are just TCP connections where Haprory read the SNI header in ordre to redirect the stream to the right peer.

eaufavor commented 2 months ago

Hi, is there any plan to add documentation about TCP handling ?

I'm not sure what exactly being asked here. We do have docs for all the APIs we expose (L4 related APIs). We also have an example of L4 proxy.

You can probably build an SNI sniffing logic on top of the APIs we provide but Pingora at the moment does not offer a full-fledged L4 proxy.

Duvieusam commented 2 months ago

Ok thanks for the info

github-actions[bot] commented 2 months ago

This question has been stale for a week. It will be closed in an additional day if not updated.

github-actions[bot] commented 2 months ago

This issue has been closed because it has been stalled with no activity.