fn detect_draft_from_setup(
buf: &[u8],
side: ProxySide,
fallback: DraftVersion,
) -> Option<DraftVersion>Expand description
Try to detect the concrete draft version by peeking at the first SETUP message on a control stream.
- On the
ClientToProxydirection, looks at CLIENT_SETUP’ssupported_versionslist and returns the highest draft in the 07–14 range we support. - On the
RelayToProxydirection, looks at SERVER_SETUP’sselected_versionand returns the matching draft. - For draft-15+ the SETUP carries no version, but those cases don’t reach this function because the caller only invokes it when the draft isn’t already fixed by ALPN.
Returns None if the buffer doesn’t yet contain enough bytes for a
decision, or if the first message isn’t a SETUP we recognize. The
caller keeps buffering and retries.
fallback is the session’s configured default draft, used only to
reject impossible answers (e.g., SERVER_SETUP selected_version outside
the supported range).