Hi [email protected],
I'd like to propose two new plugin APIs, added in PR #13919
(https://github.com/apache/trafficserver/pull/13919):
TSReturnCode TSVConnProtocolStackGet(TSVConn vconn, int count,
const char **result, int *actual);
const char *TSVConnProtocolStackContains(TSVConn vconn, char const
*tag);
*Motivation*
With the OpenSSL QUIC backend, #13919 makes TS_SSL_CLIENT_HELLO_HOOK fire
for HTTP/3 connections, as it already does for TCP. Plugins that
fingerprint the ClientHello, such as ja4_fingerprint and jax_fingerprint,
need to know whether the connection is QUIC: JA4 starts with "q" for QUIC
and "t" for TCP.
The existing protocol stack APIs all take a transaction or a session
(TSHttpTxnClientProtocolStackGet/Contains,
TSHttpSsnClientProtocolStackGet/Contains,
TSHttpTxnServerProtocolStackGet/Contains). During the TLS handshake there
is no session yet; the plugin only has the TSVConn.
*Semantics*
The two functions mirror their TSHttpSsnClientProtocolStack counterparts,
but they read the net VConnection's protocol stack:
- TSVConnProtocolStackGet() fills result with up to count protocol tags,
from the highest layer to the lowest, and sets actual to the stack's
full depth.
- TSVConnProtocolStackContains() returns the normalized tag if tag is
present, or nullptr if it isn't. Matching is an anchored prefix match,
as for the existing functions.
Because the application protocol hasn't been negotiated during the
handshake, the stack starts at the transport. For an HTTP/3 connection it
is "quic,tls/1.3,udp,ipv4". A typical check:
bool is_quic = TSVConnProtocolStackContains(vconn, TS_PROTO_TAG_QUIC)
!= nullptr;
*Implementation*
Both are thin wrappers over NetVConnection::populate_protocol() and
NetVConnection::protocol_contains(), the same calls the session variants
make. They are documented in TSClientProtocolStack.en.rst and noted in
whats-new.en.rst. ja4_fingerprint and jax_fingerprint use
TSVConnProtocolStackContains(), and an HTTP/3 urtest checks the stack
that TSVConnProtocolStackGet() reports in a ClientHello hook.
Let me know if you have any thoughts or concerns.
Thanks,
Brian
--
"Come to Me, all who are weary and heavy-laden, and I will
give you rest. Take My yoke upon you and learn from Me, for
I am gentle and humble in heart, and you will find rest for
your souls. For My yoke is easy and My burden is light."
~ Matthew 11:28-30