Skip to main content

detect_draft_from_setup

Function detect_draft_from_setup 

Source
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 ClientToProxy direction, looks at CLIENT_SETUP’s supported_versions list and returns the highest draft in the 07–14 range we support.
  • On the RelayToProxy direction, looks at SERVER_SETUP’s selected_version and 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).