wreq 1.3.2.1 → 1.3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +40 -52
  3. data/Cargo.toml +11 -8
  4. data/README.md +12 -5
  5. data/VERSION +1 -1
  6. data/crates/README.md +5 -0
  7. data/crates/wreq-util/Cargo.toml +1 -0
  8. data/crates/wreq-util/src/emulate/macros.rs +31 -197
  9. data/crates/wreq-util/src/emulate/profile/chromium/chrome.rs +731 -0
  10. data/crates/wreq-util/src/emulate/profile/chromium/edge.rs +418 -0
  11. data/crates/wreq-util/src/emulate/profile/chromium/header.rs +74 -0
  12. data/crates/wreq-util/src/emulate/profile/chromium/http2.rs +59 -0
  13. data/crates/wreq-util/src/emulate/profile/chromium/opera.rs +312 -0
  14. data/crates/wreq-util/src/emulate/profile/{chrome → chromium}/tls.rs +146 -137
  15. data/crates/wreq-util/src/emulate/profile/chromium.rs +9 -0
  16. data/crates/wreq-util/src/emulate/profile/firefox/header.rs +48 -54
  17. data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +92 -102
  18. data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +155 -146
  19. data/crates/wreq-util/src/emulate/profile/firefox.rs +312 -440
  20. data/crates/wreq-util/src/emulate/profile.rs +5 -7
  21. data/crates/wreq-util/src/emulate.rs +34 -1
  22. data/crates/wreq-util/tests/client.rs +187 -46
  23. data/crates/wreq-util/tests/emulate_chrome.rs +17 -0
  24. data/crates/wreq-util/tests/emulate_firefox.rs +15 -0
  25. data/crates/wreq-util/tests/emulate_opera.rs +24 -0
  26. data/lib/wreq_ruby/emulate.rb +28 -0
  27. data/src/emulate.rs +28 -5
  28. data/test/emulation_client_hello_test.rb +142 -0
  29. data/test/emulation_test.rb +21 -104
  30. data/wreq.gemspec +1 -1
  31. metadata +11 -10
  32. data/crates/wreq-util/src/emulate/profile/chrome/header.rs +0 -116
  33. data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +0 -65
  34. data/crates/wreq-util/src/emulate/profile/chrome.rs +0 -2269
  35. data/crates/wreq-util/src/emulate/profile/opera/header.rs +0 -29
  36. data/crates/wreq-util/src/emulate/profile/opera/http2.rs +0 -50
  37. data/crates/wreq-util/src/emulate/profile/opera/tls.rs +0 -103
  38. data/crates/wreq-util/src/emulate/profile/opera.rs +0 -299
@@ -0,0 +1,312 @@
1
+ use super::super::{Emulation, HeaderMap, Platform, build_standard_emulation};
2
+ use super::{header, http2, tls};
3
+
4
+ chromium_profile!(
5
+ opera116,
6
+ tls: tls::Preset::ResumptionWithMlkem,
7
+ http2: http2::Preset::NoPush,
8
+ headers: header::Preset::ZstdWithPriority,
9
+ brands: r#""Opera";v="116", "Chromium";v="131", "Not_A Brand";v="24""#,
10
+ [
11
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0"),
12
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0"),
13
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0")
14
+ ]
15
+ );
16
+
17
+ chromium_profile!(
18
+ opera117,
19
+ transport: opera116::build_emulation,
20
+ headers: header::Preset::ZstdWithPriority,
21
+ brands: r#""Not A(Brand";v="8", "Chromium";v="132", "Opera";v="117""#,
22
+ [
23
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0"),
24
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0"),
25
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0")
26
+ ]
27
+ );
28
+
29
+ chromium_profile!(
30
+ opera118,
31
+ transport: opera116::build_emulation,
32
+ headers: header::Preset::ZstdWithPriority,
33
+ brands: r#""Not(A:Brand";v="99", "Opera";v="118", "Chromium";v="133""#,
34
+ [
35
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0"),
36
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0"),
37
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0")
38
+ ]
39
+ );
40
+
41
+ chromium_profile!(
42
+ opera119,
43
+ transport: opera116::build_emulation,
44
+ headers: header::Preset::ZstdWithPriority,
45
+ brands: r#""Chromium";v="134", "Not:A-Brand";v="24", "Opera";v="119""#,
46
+ [
47
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0"),
48
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0"),
49
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0")
50
+ ]
51
+ );
52
+
53
+ chromium_profile!(
54
+ opera120,
55
+ transport: opera116::build_emulation,
56
+ headers: header::Preset::ZstdWithPriority,
57
+ brands: r#""Chromium";v="135", "Not:A-Brand";v="24", "Opera";v="120""#,
58
+ [
59
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0"),
60
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0"),
61
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0")
62
+ ]
63
+ );
64
+
65
+ chromium_profile!(
66
+ opera121,
67
+ transport: opera116::build_emulation,
68
+ headers: header::Preset::ZstdWithPriority,
69
+ brands: r#""Opera";v="121", "Chromium";v="137", "Not/A)Brand";v="24""#,
70
+ [
71
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0"),
72
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0"),
73
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0")
74
+ ]
75
+ );
76
+
77
+ chromium_profile!(
78
+ opera122,
79
+ transport: opera116::build_emulation,
80
+ headers: header::Preset::ZstdWithPriority,
81
+ brands: r#""Chromium";v="138", "Not=A?Brand";v="24", "Opera";v="122""#,
82
+ [
83
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0"),
84
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0"),
85
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0")
86
+ ]
87
+ );
88
+
89
+ chromium_profile!(
90
+ opera123,
91
+ transport: opera116::build_emulation,
92
+ headers: header::Preset::ZstdWithPriority,
93
+ brands: r#""Chromium";v="139", "Not=A?Brand";v="24", "Opera";v="123""#,
94
+ [
95
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0"),
96
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0"),
97
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0")
98
+ ]
99
+ );
100
+
101
+ chromium_profile!(
102
+ opera124,
103
+ transport: opera116::build_emulation,
104
+ headers: header::Preset::ZstdWithPriority,
105
+ brands: r#""Chromium";v="140", "Not=A?Brand";v="24", "Opera";v="124""#,
106
+ [
107
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0"),
108
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0"),
109
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0")
110
+ ]
111
+ );
112
+
113
+ chromium_profile!(
114
+ opera125,
115
+ transport: opera116::build_emulation,
116
+ headers: header::Preset::ZstdWithPriority,
117
+ brands: r#""Opera";v="125", "Not?A_Brand";v="8", "Chromium";v="141""#,
118
+ [
119
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0"),
120
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0"),
121
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0")
122
+ ]
123
+ );
124
+
125
+ chromium_profile!(
126
+ opera126,
127
+ transport: opera116::build_emulation,
128
+ headers: header::Preset::ZstdWithPriority,
129
+ brands: r#""Not:A-Brand";v="99", "Opera";v="126", "Chromium";v="142""#,
130
+ [
131
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0"),
132
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0"),
133
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0")
134
+ ]
135
+ );
136
+
137
+ chromium_profile!(
138
+ opera127,
139
+ transport: opera116::build_emulation,
140
+ headers: header::Preset::ZstdWithPriority,
141
+ brands: r#""Not:A-Brand";v="99", "Opera";v="127", "Chromium";v="143""#,
142
+ [
143
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0"),
144
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0"),
145
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0")
146
+ ]
147
+ );
148
+
149
+ chromium_profile!(
150
+ opera128,
151
+ transport: opera116::build_emulation,
152
+ headers: header::Preset::ZstdWithPriority,
153
+ brands: r#""Not:A-Brand";v="99", "Opera";v="128", "Chromium";v="144""#,
154
+ [
155
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0"),
156
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0"),
157
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0")
158
+ ]
159
+ );
160
+
161
+ chromium_profile!(
162
+ opera129,
163
+ transport: opera116::build_emulation,
164
+ headers: header::Preset::ZstdWithPriority,
165
+ brands: r#""Not:A-Brand";v="99", "Opera";v="129", "Chromium";v="145""#,
166
+ [
167
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0"),
168
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0"),
169
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0")
170
+ ]
171
+ );
172
+
173
+ chromium_profile!(
174
+ opera130,
175
+ transport: opera116::build_emulation,
176
+ headers: header::Preset::ZstdWithPriority,
177
+ brands: r#""Not:A-Brand";v="99", "Opera";v="130", "Chromium";v="146""#,
178
+ [
179
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0"),
180
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0"),
181
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0")
182
+ ]
183
+ );
184
+
185
+ chromium_profile!(
186
+ opera131,
187
+ transport: opera116::build_emulation,
188
+ headers: header::Preset::ZstdWithPriority,
189
+ brands: r#""Opera";v="131", "Not.A/Brand";v="8", "Chromium";v="147""#,
190
+ [
191
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0"),
192
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0"),
193
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0")
194
+ ]
195
+ );
196
+
197
+ // Reuse Chromium's TLS defaults with Opera's existing HTTP/2 settings.
198
+ // Brand hints use Chromium's milestone seed with Opera as the product brand.
199
+ chromium_profile!(
200
+ opera132,
201
+ tls: tls::Preset::MlkemNewAlps,
202
+ http2: http2::Preset::NoPush,
203
+ headers: header::Preset::ZstdWithPriority,
204
+ brands: r#""Chromium";v="148", "Opera";v="132", "Not/A)Brand";v="99""#,
205
+ [
206
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 OPR/132.0.0.0"),
207
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 OPR/132.0.0.0"),
208
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 OPR/132.0.0.0")
209
+ ]
210
+ );
211
+
212
+ chromium_profile!(
213
+ opera133,
214
+ transport: opera132::build_emulation,
215
+ headers: header::Preset::ZstdWithPriority,
216
+ brands: r#""Opera";v="133", "Chromium";v="149", "Not)A;Brand";v="24""#,
217
+ [
218
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 OPR/133.0.0.0"),
219
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 OPR/133.0.0.0"),
220
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 OPR/133.0.0.0")
221
+ ]
222
+ );
223
+
224
+ chromium_profile!(
225
+ opera134,
226
+ tls: tls::Preset::MlkemNewAlpsWithMldsa,
227
+ http2: http2::Preset::NoPush,
228
+ headers: header::Preset::ZstdWithPriority,
229
+ brands: r#""Not;A=Brand";v="8", "Chromium";v="150", "Opera";v="134""#,
230
+ [
231
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 OPR/134.0.0.0"),
232
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 OPR/134.0.0.0"),
233
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 OPR/134.0.0.0")
234
+ ]
235
+ );
236
+
237
+ chromium_profile!(
238
+ opera135,
239
+ transport: opera134::build_emulation,
240
+ headers: header::Preset::ZstdWithPriority,
241
+ brands: r#""Not=A?Brand";v="99", "Opera";v="135", "Chromium";v="151""#,
242
+ [
243
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 OPR/135.0.0.0"),
244
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 OPR/135.0.0.0"),
245
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 OPR/135.0.0.0")
246
+ ]
247
+ );
248
+
249
+ // Use Chromium's shuffled Trust Anchor IDs with Opera's existing HTTP/2 settings.
250
+ chromium_profile!(
251
+ opera136,
252
+ tls: tls::Preset::ShuffledTrustAnchorIds,
253
+ http2: http2::Preset::NoPush,
254
+ headers: header::Preset::ZstdWithPriority,
255
+ brands: r#""Chromium";v="152", "Not?A_Brand";v="24", "Opera";v="136""#,
256
+ [
257
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 OPR/136.0.0.0"),
258
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 OPR/136.0.0.0"),
259
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 OPR/136.0.0.0")
260
+ ]
261
+ );
262
+
263
+ chromium_profile!(
264
+ opera137,
265
+ transport: opera136::build_emulation,
266
+ headers: header::Preset::ZstdWithPriority,
267
+ brands: r#""Opera";v="137", "Not_A Brand";v="8", "Chromium";v="153""#,
268
+ [
269
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 OPR/137.0.0.0"),
270
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 OPR/137.0.0.0"),
271
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 OPR/137.0.0.0")
272
+ ]
273
+ );
274
+
275
+ // Switch from shuffled to sorted Trust Anchor IDs.
276
+ chromium_profile!(
277
+ opera138,
278
+ tls: tls::Preset::SortedTrustAnchorIds,
279
+ http2: http2::Preset::NoPush,
280
+ headers: header::Preset::ZstdWithPriority,
281
+ brands: r#""Chromium";v="154", "Opera";v="138", "Not A(Brand";v="99""#,
282
+ [
283
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 OPR/138.0.0.0"),
284
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 OPR/138.0.0.0"),
285
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 OPR/138.0.0.0")
286
+ ]
287
+ );
288
+
289
+ // Reuse Chromium's JPEG XL navigation headers without changing the Opera transport.
290
+ chromium_profile!(
291
+ opera139,
292
+ transport: opera138::build_emulation,
293
+ headers: header::Preset::Jxl,
294
+ brands: r#""Opera";v="139", "Chromium";v="155", "Not(A:Brand";v="24""#,
295
+ [
296
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 OPR/139.0.0.0"),
297
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 OPR/139.0.0.0"),
298
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 OPR/139.0.0.0")
299
+ ]
300
+ );
301
+
302
+ chromium_profile!(
303
+ opera140,
304
+ transport: opera138::build_emulation,
305
+ headers: header::Preset::Jxl,
306
+ brands: r#""Not-A.Brand";v="99", "Opera";v="140", "Chromium";v="157""#,
307
+ [
308
+ (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 OPR/140.0.0.0"),
309
+ (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 OPR/140.0.0.0"),
310
+ (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 OPR/140.0.0.0")
311
+ ]
312
+ );
@@ -1,73 +1,150 @@
1
- use super::*;
1
+ use super::super::{
2
+ AlpsProtocol, BrotliCompressor, CertificateCompressor, EchGrease, EchGreaseAead, Tls13Cipher,
3
+ TlsOptions, TlsVersion,
4
+ };
2
5
 
3
- macro_rules! tls_options {
4
- (@build $builder:expr) => {
5
- $builder.build().into()
6
- };
6
+ #[derive(Clone, Copy)]
7
+ pub(super) enum Preset {
8
+ ClassicGroups,
9
+ EchGrease,
10
+ PermutedExtensions,
11
+ PermutedExtensionsWithEchGrease,
12
+ Resumption,
13
+ ResumptionWithKyber,
14
+ ResumptionWithMlkem,
15
+ MlkemNewAlps,
16
+ MlkemNewAlpsWithMldsa,
17
+ ShuffledTrustAnchorIds,
18
+ SortedTrustAnchorIds,
19
+ EdgeSignatureGrease,
20
+ }
7
21
 
8
- (1) => {
9
- tls_options!(@build ChromeTlsConfig::builder())
10
- };
11
- (2) => {
12
- tls_options!(@build ChromeTlsConfig::builder().enable_ech_grease(true))
13
- };
14
- (3) => {
15
- tls_options!(@build ChromeTlsConfig::builder().permute_extensions(true))
16
- };
17
- (4) => {
18
- tls_options!(@build ChromeTlsConfig::builder()
19
- .permute_extensions(true)
20
- .enable_ech_grease(true))
21
- };
22
- (5) => {
23
- tls_options!(@build ChromeTlsConfig::builder()
24
- .permute_extensions(true)
25
- .enable_ech_grease(true)
26
- .pre_shared_key(true))
27
- };
28
- (6, $curves:expr) => {
29
- tls_options!(@build ChromeTlsConfig::builder()
30
- .permute_extensions(true)
31
- .enable_ech_grease(true)
32
- .pre_shared_key(true)
33
- .curves($curves))
34
- };
35
- (7, $curves:expr) => {
36
- tls_options!(@build ChromeTlsConfig::builder()
37
- .permute_extensions(true)
38
- .enable_ech_grease(true)
39
- .pre_shared_key(true)
40
- .curves($curves)
41
- .alps_use_new_codepoint(true))
42
- };
43
- (8, $curves:expr, $sigalgs:expr) => {
44
- tls_options!(@build ChromeTlsConfig::builder()
45
- .permute_extensions(true)
46
- .enable_ech_grease(true)
47
- .pre_shared_key(true)
48
- .curves($curves)
49
- .sigalgs_list($sigalgs)
50
- .alps_use_new_codepoint(true))
51
- };
52
- (9, $curves:expr) => {
53
- tls_options!(9, $curves, shuffled_trust_anchors(crate::rand::fast_random))
54
- };
55
- (9, $curves:expr, $trust_anchors:expr) => {
56
- tls_options!(@build ChromeTlsConfig::builder()
57
- .permute_extensions(true)
58
- .enable_ech_grease(true)
59
- .pre_shared_key(true)
60
- .curves($curves)
61
- .sigalgs_list(NEW_SIGALGS_LIST)
62
- .trust_anchors($trust_anchors)
63
- .grease_sigalgs_enabled(true)
64
- .alps_use_new_codepoint(true))
65
- };
22
+ struct Settings {
23
+ curves: &'static str,
24
+ sigalgs: &'static str,
25
+ permute_extensions: bool,
26
+ ech_grease: bool,
27
+ pre_shared_key: bool,
28
+ new_alps: bool,
29
+ grease_sigalgs: Option<bool>,
30
+ trust_anchors: Option<TrustAnchorOrder>,
66
31
  }
67
32
 
68
- pub const CURVES_1: &str = join!(":", "X25519", "P-256", "P-384");
69
- pub const CURVES_2: &str = join!(":", "X25519Kyber768Draft00", "X25519", "P-256", "P-384");
70
- pub const CURVES_3: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384");
33
+ enum TrustAnchorOrder {
34
+ Shuffled,
35
+ Sorted,
36
+ }
37
+
38
+ impl Preset {
39
+ pub(super) fn build(self) -> TlsOptions {
40
+ const CLASSIC: Settings = Settings {
41
+ curves: CLASSIC_X25519_GROUPS,
42
+ sigalgs: SIGALGS_LIST,
43
+ permute_extensions: false,
44
+ ech_grease: false,
45
+ pre_shared_key: false,
46
+ new_alps: false,
47
+ grease_sigalgs: None,
48
+ trust_anchors: None,
49
+ };
50
+
51
+ const PERMUTED_ECH: Settings = Settings {
52
+ permute_extensions: true,
53
+ ech_grease: true,
54
+ ..CLASSIC
55
+ };
56
+
57
+ const RESUMPTION: Settings = Settings {
58
+ pre_shared_key: true,
59
+ ..PERMUTED_ECH
60
+ };
61
+
62
+ const MLKEM_NEW_ALPS: Settings = Settings {
63
+ curves: MLKEM_GROUPS,
64
+ new_alps: true,
65
+ ..RESUMPTION
66
+ };
67
+
68
+ const MLDSA: Settings = Settings {
69
+ sigalgs: SIGALGS_WITH_MLDSA,
70
+ ..MLKEM_NEW_ALPS
71
+ };
72
+
73
+ const SIGNATURE_GREASE: Settings = Settings {
74
+ grease_sigalgs: Some(true),
75
+ ..MLDSA
76
+ };
77
+
78
+ let settings = match self {
79
+ Self::ClassicGroups => CLASSIC,
80
+ Self::EchGrease => Settings {
81
+ ech_grease: true,
82
+ ..CLASSIC
83
+ },
84
+ Self::PermutedExtensions => Settings {
85
+ permute_extensions: true,
86
+ ..CLASSIC
87
+ },
88
+ Self::PermutedExtensionsWithEchGrease => PERMUTED_ECH,
89
+ Self::Resumption => RESUMPTION,
90
+ Self::ResumptionWithKyber => Settings {
91
+ curves: KYBER_DRAFT_GROUPS,
92
+ ..RESUMPTION
93
+ },
94
+ Self::ResumptionWithMlkem => Settings {
95
+ curves: MLKEM_GROUPS,
96
+ ..RESUMPTION
97
+ },
98
+ Self::MlkemNewAlps => MLKEM_NEW_ALPS,
99
+ Self::MlkemNewAlpsWithMldsa => MLDSA,
100
+ Self::ShuffledTrustAnchorIds => Settings {
101
+ trust_anchors: Some(TrustAnchorOrder::Shuffled),
102
+ ..SIGNATURE_GREASE
103
+ },
104
+ Self::SortedTrustAnchorIds => Settings {
105
+ trust_anchors: Some(TrustAnchorOrder::Sorted),
106
+ ..SIGNATURE_GREASE
107
+ },
108
+ Self::EdgeSignatureGrease => SIGNATURE_GREASE,
109
+ };
110
+
111
+ let builder = TlsOptions::builder()
112
+ .grease_enabled(true)
113
+ .enable_ocsp_stapling(true)
114
+ .enable_signed_cert_timestamps(true)
115
+ .curves_list(settings.curves)
116
+ .sigalgs_list(settings.sigalgs)
117
+ .cipher_list(CIPHER_LIST)
118
+ .tls13_cipher_list(TLS13_CIPHER_LIST)
119
+ .min_tls_version(TlsVersion::TLS_1_2)
120
+ .max_tls_version(TlsVersion::TLS_1_3)
121
+ .permute_extensions(settings.permute_extensions)
122
+ .pre_shared_key(settings.pre_shared_key)
123
+ .ech_grease(
124
+ settings
125
+ .ech_grease
126
+ .then_some(EchGrease::Aead(EchGreaseAead::AES_128_GCM)),
127
+ )
128
+ .alps_protocols([AlpsProtocol::HTTP2])
129
+ .alps_use_new_codepoint(settings.new_alps)
130
+ .certificate_compressors(CERTIFICATE_COMPRESSORS)
131
+ .grease_sigalgs_enabled(settings.grease_sigalgs);
132
+
133
+ // Skipping this setter omits the extension; an empty list would still send it.
134
+ let builder = match settings.trust_anchors {
135
+ Some(TrustAnchorOrder::Shuffled) => {
136
+ builder.trust_anchors(shuffled_trust_anchors(crate::rand::fast_random))
137
+ }
138
+ Some(TrustAnchorOrder::Sorted) => builder.trust_anchors(sorted_trust_anchors()),
139
+ None => builder,
140
+ };
141
+ builder.build()
142
+ }
143
+ }
144
+
145
+ const CLASSIC_X25519_GROUPS: &str = join!(":", "X25519", "P-256", "P-384");
146
+ const KYBER_DRAFT_GROUPS: &str = join!(":", "X25519Kyber768Draft00", "X25519", "P-256", "P-384");
147
+ const MLKEM_GROUPS: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384");
71
148
 
72
149
  pub const CIPHER_LIST: &str = join!(
73
150
  ":",
@@ -103,7 +180,7 @@ pub const SIGALGS_LIST: &str = join!(
103
180
  "rsa_pkcs1_sha512"
104
181
  );
105
182
 
106
- pub const NEW_SIGALGS_LIST: &str = join!(
183
+ const SIGALGS_WITH_MLDSA: &str = join!(
107
184
  ":",
108
185
  "mldsa44",
109
186
  "mldsa65",
@@ -125,7 +202,7 @@ pub(super) const CHROME_TRUST_ANCHORS: &[u8] = &chromium_roots::encoded_trust_an
125
202
  // the root store's source order. Generate an order once per native configuration;
126
203
  // connections using that client configuration retain the order.
127
204
  // https://chromium.googlesource.com/chromium/src/+/f7b831a4e249fbd98eae4b391c69f70300a849d1/net/ssl/ssl_config_service.cc
128
- pub(super) fn shuffled_trust_anchors(mut random: impl FnMut() -> u64) -> Vec<u8> {
205
+ fn shuffled_trust_anchors(mut random: impl FnMut() -> u64) -> Vec<u8> {
129
206
  let mut ids = chromium_roots::trust_anchor_ids();
130
207
  for index in (1..ids.len()).rev() {
131
208
  let bound = (index + 1) as u64;
@@ -142,7 +219,7 @@ pub(super) fn shuffled_trust_anchors(mut random: impl FnMut() -> u64) -> Vec<u8>
142
219
 
143
220
  // Chrome 154 sorts the raw IDs before adding their length prefixes.
144
221
  // https://chromium.googlesource.com/chromium/src/+/731082f0a26ce4b3976c3d82943092f5d13daf13/net/cert/x509_util.cc
145
- pub(super) fn sorted_trust_anchors() -> Vec<u8> {
222
+ fn sorted_trust_anchors() -> Vec<u8> {
146
223
  let mut ids = chromium_roots::trust_anchor_ids();
147
224
  ids.sort_unstable();
148
225
  encode_trust_anchors(&ids)
@@ -161,74 +238,6 @@ fn encode_trust_anchors(ids: &[&[u8]]) -> Vec<u8> {
161
238
 
162
239
  pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&BrotliCompressor];
163
240
 
164
- #[derive(TypedBuilder)]
165
- pub struct ChromeTlsConfig {
166
- #[builder(default = CURVES_1)]
167
- curves: &'static str,
168
-
169
- #[builder(default = SIGALGS_LIST)]
170
- sigalgs_list: &'static str,
171
-
172
- #[builder(default = CIPHER_LIST)]
173
- cipher_list: &'static str,
174
-
175
- #[builder(default = AlpsProtocol::HTTP2, setter(into))]
176
- alps_protos: AlpsProtocol,
177
-
178
- #[builder(default = false)]
179
- alps_use_new_codepoint: bool,
180
-
181
- #[builder(default = false, setter(into))]
182
- enable_ech_grease: bool,
183
-
184
- #[builder(default = false, setter(into))]
185
- permute_extensions: bool,
186
-
187
- #[builder(default = false, setter(into))]
188
- pre_shared_key: bool,
189
-
190
- #[builder(default, setter(strip_option))]
191
- trust_anchors: Option<Vec<u8>>,
192
-
193
- #[builder(default, setter(strip_option))]
194
- grease_sigalgs_enabled: Option<bool>,
195
- }
196
-
197
- impl From<ChromeTlsConfig> for TlsOptions {
198
- fn from(val: ChromeTlsConfig) -> Self {
199
- let builder = TlsOptions::builder()
200
- .grease_enabled(true)
201
- .enable_ocsp_stapling(true)
202
- .enable_signed_cert_timestamps(true)
203
- .curves_list(val.curves)
204
- .sigalgs_list(val.sigalgs_list)
205
- .cipher_list(val.cipher_list)
206
- .tls13_cipher_list(TLS13_CIPHER_LIST)
207
- .min_tls_version(TlsVersion::TLS_1_2)
208
- .max_tls_version(TlsVersion::TLS_1_3)
209
- .permute_extensions(val.permute_extensions)
210
- .pre_shared_key(val.pre_shared_key)
211
- .ech_grease(
212
- val.enable_ech_grease
213
- .then_some(EchGrease::Aead(EchGreaseAead::AES_128_GCM)),
214
- )
215
- .alps_protocols([val.alps_protos])
216
- .alps_use_new_codepoint(val.alps_use_new_codepoint)
217
- .certificate_compressors(CERTIFICATE_COMPRESSORS);
218
- let builder = if let Some(trust_anchors) = val.trust_anchors {
219
- builder.trust_anchors(trust_anchors)
220
- } else {
221
- builder
222
- };
223
- let builder = if let Some(enabled) = val.grease_sigalgs_enabled {
224
- builder.grease_sigalgs_enabled(enabled)
225
- } else {
226
- builder
227
- };
228
- builder.build()
229
- }
230
- }
231
-
232
241
  #[cfg(test)]
233
242
  mod tests {
234
243
  use super::*;
@@ -0,0 +1,9 @@
1
+ //! Presets and shared options for Chromium-based browsers.
2
+
3
+ pub mod chrome;
4
+ pub(in crate::emulate) mod edge;
5
+ pub mod opera;
6
+
7
+ mod header;
8
+ mod http2;
9
+ mod tls;