Run pre-TLS callbacks for cleartext listeners - #1003
Open
CodyPubNub wants to merge 2 commits into
Open
Conversation
- process connection preambles before either TLS or cleartext protocols - document the callback's cleartext behavior - cover plain TCP listeners with a regression test
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
PreTlsProcessbefore both TLS and cleartext protocol handlingMotivation
I ran into this while adding Proxy Protocol v2 support for AWS Network Load
Balancer target groups.
Some of our NLB listeners terminate TLS and forward cleartext HTTP with a PPv2
preamble to Pingora, while others retain TLS through to Pingora. We use the
same
PreTlsProcessimplementation for both paths so it can consume thepreamble and populate the original client and destination addresses before
HTTP or TLS processing begins.
Pingora currently invokes that callback only when its listener has TLS
configured. On the TLS-terminated NLB path, the Pingora listener is cleartext,
so the callback is skipped and the HTTP parser receives the binary PPv2 header
instead of the request line.
Invoking the existing callback before selecting the TLS or cleartext path lets
the same connection-preamble handler support both configurations without
introducing another hook.
Follow-up to #799. Refs #132.
API naming
The cleartext case came up during review of #799, where
post_l4_handshakewas suggested as a name that would describe both TLS andnon-TLS listeners.
I kept the existing
PreTlsProcessAPI in this PR to keep the implementationfocused, but that means its name no longer describes its full behavior. It also
means an existing callback configured on a mixed TLS/cleartext
Listenerscollection would begin running for its cleartext endpoints.
Would maintainers prefer to:
I am happy to adjust this before merge. I have avoided introducing a parallel
hook or additional feature gating until there is a preferred direction,
particularly since those choices can add permanent complexity or work to the
connection path for applications that do not opt in.