refactor: generalize and harden masquerade reverse proxy - #1669
Open
giveup wants to merge 2 commits into
Open
Conversation
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor
masquerade.proxyinto a reusable, production-ready single-upstream reverse proxy and improve the HTTP behavior of the masquerade server.Motivation
The masquerade proxy should behave like a normal Go web application backed by
quic-go, rather than trying to imitate a specific server implementation.Unauthenticated requests should be handled entirely by the configured backend, while authenticated Hysteria requests continue to use the existing proxy protocol. The reverse proxy therefore needs reliable support for common HTTP application behavior such as streaming responses, request streaming, WebSocket upgrades, trailers, cancellation, connection reuse, and graceful shutdown.
What's New
extras/masq.rewriteHost,xForwarded, path, query, and error-handling behavior.masquerade.proxy.flushIntervalsetting.Alt-Svcheaders so the backend cannot advertise an incorrect or private endpoint.masquerade.advertisedQUICPortfor deployments where the public QUIC port differs from the local UDP listener port.Example
advertisedQUICPortis only needed when the public QUIC port differs from the local UDP listener port:If
advertisedQUICPortis omitted, the port fromlistenis used.Tests
python3 hyperbole.py formatpython3 hyperbole.py tidypython3 hyperbole.py test corecd extras && go test ./masqcd app && go test ./cmdcd core && go test -race ./servercd extras && go test -race ./masqcd app && go test -race ./cmdcd core && go vet ./servercd extras && go vet ./masqcd app && go vet ./cmd