http_quik/profile/mod.rs
1//! Data-only definitions for Chrome transport identity profiles.
2//!
3//! This module defines the configuration schemas used by the `tls` and `http2`
4//! modules to construct browser-identical network handshakes. No protocol
5//! logic resides here; these structures serve as the single source of truth
6//! for all fingerprint-sensitive parameters.
7//!
8//! Each [`ChromeProfile`] encodes a complete, multi-layer network identity
9//! spanning TLS (Layer 4), HTTP/2 (Layer 5), and HTTP metadata (Layer 7).
10
11use boring::ssl::SslVersion;
12
13pub mod chrome_134;
14pub mod chrome_147;
15
16/// Alias for BoringSSL's internal version type.
17pub type TlsVersion = SslVersion;
18
19/// Target operating system and CPU architecture.
20///
21/// The platform determines OS-specific protocol parameters (ALPS payload
22/// length, User-Agent string, Client Hint values) and is used by
23/// [`chrome_134::profile_auto`] to align the network persona with the
24/// host kernel's TCP/IP characteristics.
25#[derive(Debug, Clone, Copy, PartialEq, Eq)]
26pub enum Platform {
27 /// macOS on Apple Silicon (M1/M2/M3/M4).
28 MacOsArm,
29 /// macOS on Intel x86-64.
30 MacOsX86,
31 /// Windows 10/11 on x86-64.
32 WindowsX64,
33 /// Linux (Ubuntu, Debian, etc.) on x86-64.
34 LinuxX64,
35}
36
37/// Configuration for the TLS 1.2/1.3 handshake layer.
38///
39/// This structure defines the Layer 4 identity of the client. Small changes
40/// here (such as the order of cipher suites) will change the JA3/JA4
41/// fingerprint and can lead to immediate detection.
42#[derive(Debug, Clone, Copy, PartialEq, Eq)]
43pub struct TlsProfile {
44 /// Minimum allowed TLS version (typically TLS 1.2).
45 pub min_version: TlsVersion,
46 /// Maximum allowed TLS version (typically TLS 1.3).
47 pub max_version: TlsVersion,
48 /// Colon-separated list of cipher suites in OpenSSL format.
49 ///
50 /// Precision in the order of this list is critical as it directly
51 /// impacts the JA3/JA4 fingerprint.
52 pub cipher_list: &'static str,
53 /// Numeric IDs for supported elliptic curve groups.
54 pub curves: &'static [u16],
55 /// Whether to enable TLS GREASE (RFC 8701) to simulate randomized extensions.
56 pub grease_enabled: bool,
57 /// Whether to permute (shuffle) TLS extensions per connection.
58 pub permute_extensions: bool,
59 /// Whether to send a dummy ECH (Encrypted Client Hello) extension for GREASE.
60 pub enable_ech_grease: bool,
61 /// Whether to enable ALPS (Application-Layer Protocol Settings).
62 pub alps_enabled: bool,
63 /// Whether to use the draft-01 or final ALPS codepoint.
64 pub alps_use_new_codepoint: bool,
65 /// Additional H2 SETTINGS IDs to append in the ALPS payload.
66 ///
67 /// Windows and Linux Chrome include an extra setting (ID 31386) in the
68 /// ALPS handshake data that macOS omits. Each tuple is `(id, value)`.
69 pub alps_extra_settings: &'static [(u16, u32)],
70 /// Whether to support RFC 8879 certificate compression (Brotli).
71 pub compress_certificate: bool,
72 /// Whether to enable stateless session tickets for fast reconnection.
73 pub session_ticket_enabled: bool,
74 /// Ordered list of ALPN protocol identifiers.
75 pub alpn_protocols: &'static [&'static [u8]],
76 /// Ordered list of signature algorithm IDs (used for JA4_r).
77 pub sigalgs: &'static [u16],
78 /// Whether to verify the server's certificate chain.
79 ///
80 /// Real browsers always verify certificates. Disable only for testing or
81 /// local proxy interception.
82 pub verify_peer: bool,
83}
84
85/// Initial HTTP/2 SETTINGS frame parameters.
86///
87/// The values and the *order* in which they are sent are used by Akamai
88/// and other WAFs to identify the client implementation.
89#[derive(Debug, Clone, Copy, PartialEq, Eq)]
90pub struct SettingsFrame {
91 /// SETTINGS_HEADER_TABLE_SIZE (ID 0x1).
92 pub header_table_size: u32,
93 /// SETTINGS_ENABLE_PUSH (ID 0x2).
94 pub enable_push: bool,
95 /// SETTINGS_INITIAL_WINDOW_SIZE (ID 0x4).
96 pub initial_window_size: u32,
97 /// SETTINGS_MAX_HEADER_LIST_SIZE (ID 0x6).
98 pub max_header_list_size: u32,
99}
100
101/// Configuration for the HTTP/2 protocol layer.
102///
103/// Defines the Layer 5 identity, focusing on behavioral markers like
104/// pseudo-header ordering and stream priority.
105#[derive(Debug, Clone, Copy, PartialEq, Eq)]
106pub struct Http2Profile {
107 /// Initial SETTINGS frame values and order.
108 pub settings: SettingsFrame,
109 /// Total connection-level window size (default + delta).
110 ///
111 /// This value determines the initial `WINDOW_UPDATE` frame increment
112 /// sent immediately after the handshake. Chrome uses a specific non-standard
113 /// increment that acts as a strong identity signal.
114 pub initial_connection_window_size: u32,
115 /// Ordering of pseudo-headers (e.g., :method, :authority, :scheme, :path).
116 pub pseudo_order: [PseudoOrder; 4],
117 /// Priority parameters for the initial HEADERS frame.
118 pub headers_priority: HeadersPriority,
119}
120
121/// Stream priority parameters embedded in the HEADERS frame.
122#[derive(Debug, Clone, Copy, PartialEq, Eq)]
123pub struct HeadersPriority {
124 /// Stream ID that this request depends on (typically 0).
125 pub dep: u32,
126 /// Priority weight (0-255).
127 pub weight: u8,
128 /// Whether this dependency is exclusive.
129 pub exclusive: bool,
130}
131
132/// Canonical HTTP/2 pseudo-header identifiers.
133#[derive(Debug, Clone, Copy, PartialEq, Eq)]
134pub enum PseudoOrder {
135 /// `:method`
136 Method,
137 /// `:authority`
138 Authority,
139 /// `:scheme`
140 Scheme,
141 /// `:path`
142 Path,
143}
144
145/// Chrome-specific HTTP header values and Client Hint metadata.
146///
147/// These values are injected into every outbound request and must match
148/// the declared platform. WAFs cross-check `sec-ch-ua-platform` against
149/// the TLS handshake and TCP stack to detect spoofed identities.
150#[derive(Debug, Clone, PartialEq, Eq)]
151pub struct HeaderProfile {
152 /// Full `User-Agent` header value.
153 pub user_agent: String,
154 /// `sec-ch-ua` Client Hint brand list.
155 pub sec_ch_ua: String,
156 /// `sec-ch-ua-platform` Client Hint (e.g., `"macOS"`, `"Windows"`, `"Linux"`).
157 pub sec_ch_ua_platform: String,
158 /// `sec-ch-ua-platform-version` Client Hint.
159 ///
160 /// Must match the host OS: Windows 11 reports `"15.0.0"`,
161 /// macOS Sequoia reports `"15.0.0"`, Linux reports `"0.0.0"`.
162 pub sec_ch_ua_platform_version: String,
163 /// Whether to include the RFC 9218 `priority` header (e.g., `u=0, i`).
164 pub include_priority_header: bool,
165 /// Whether to advertise `zstd` in the `accept-encoding` header.
166 pub zstd_encoding: bool,
167 /// The Accept-Language header value.
168 pub accept_language: String,
169}
170
171/// A complete, multi-layer identity profile for a Chrome instance.
172///
173/// Combines TLS, HTTP/2, and HTTP metadata into a single configuration
174/// that, when applied, makes the transport layer indistinguishable from
175/// the specified Chrome version and platform.
176#[derive(Debug, Clone, PartialEq, Eq)]
177pub struct ChromeProfile {
178 /// Major Chrome version (e.g., `134`).
179 pub version: u32,
180 /// Target operating system and architecture.
181 pub platform: Platform,
182 /// TLS handshake configuration (JA3/JA4 fingerprint source).
183 pub tls: TlsProfile,
184 /// HTTP/2 handshake configuration (Akamai fingerprint source).
185 pub h2: Http2Profile,
186 /// HTTP-level metadata and Client Hints.
187 pub headers: HeaderProfile,
188}