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

feat(caddy): add a WebSockets handler #216

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

sbruens
Copy link

@sbruens sbruens commented Sep 23, 2024

No description provided.

@@ -10,7 +10,42 @@
"apps": {
"http": {
"servers": {
"": {
"srv0": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a weird name. Should we call it "main"? Or "primary"?

"handle": [
{
"handler": "websocket",
"backend": ":9000"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this drops the client IP. We would need something like the PROXY protocol, in which case we should use unix sockets instead of TCP/UDP. But there's a better way.

We should create a a websocket Layer-4 reverse proxy instead, that plugs directly into the layer-4 handler and avoid extra dialing and relaying. It also remove the need for a port.

ws2endpoint can serve as inspiration: https://github.com/Jigsaw-Code/outline-sdk/blob/fe5dc64d1503712f68d53085aa5e53e3d0ea7270/x/examples/ws2endpoint/main.go#L71

Though I see it as being a connection that wraps the http.ResponseWriter and http.Request and is passed to the SS handler.

case "udp":
packetDialer := &transport.UDPDialer{}
endpoint := transport.PacketDialerEndpoint{Dialer: packetDialer, Address: backendAddr.JoinHostPort(0)}
handler = func(wsConn *websocket.Conn) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants