//! Real, per-browser TLS `ClientHello` shapes for `steal` mode, built with
//! the same library (`boring`, Cloudflare's BoringSSL bindings) that real
//! Chrome releases are built on -- rather than the hand-shaped minimal hello
//! in [`crate::steal`], which uses a small, plausible but not
//! browser-accurate cipher/extension set.
//!
//! No real TLS session is ever completed here. `steal` mode's client side
//! is not a real TLS client: it sends one `ClientHello` record carrying a
//! tag in `session_id` and then immediately speaks the snolc protocol on
//! the same raw bytes -- there is no `ServerHello` to wait for when talking
//! to a real snolc server. So to get the exact bytes real BoringSSL would
//! put on the wire for a given fingerprint, this drives a real (and
//! intentionally never-finishing) handshake against a throwaway local
//! loopback listener and captures whatever the client wrote before it
//! blocked waiting for a response that will never come.
//!
//! `session_id` sits at a fixed byte offset (44..76) in every TLS 1.2/1.3
//! `ClientHello`, before any of the variable-length fields the fingerprint
//! actually varies (cipher suites, extensions, ALPN, curves...), so
//! [`crate::steal::patch_session_id_tag`] can overwrite it after the fact
//! regardless of which generator produced the rest of the record.
use boring::ssl::{SslConnector, SslMethod, SslVerifyMode, SslVersion};
use tokio::io::AsyncReadExt;
use tokio::net::{TcpListener, TcpStream};
use crate::config::Fingerprint;
use crate::error::{Error, Result};
/// Largest `ClientHello` this module will ever capture; real browser
/// hellos (with session tickets/GREASE/ALPN) are well under this.
const MAX_CAPTURED_HELLO: usize = 8192;
/// Builds the exact `ClientHello` bytes BoringSSL produces for `fingerprint`
/// with `sni` as the server name, or `Ok(None)` for [`Fingerprint::None`]
/// (the caller should use [`crate::steal::client_hello`]'s hand-built hello
/// instead).
pub async fn client_hello_bytes(fingerprint: Fingerprint, sni: &str) -> Result