wreq 1.2.4 → 1.2.5
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.
- checksums.yaml +4 -4
- data/Cargo.lock +3 -7
- data/Cargo.toml +6 -1
- data/crates/wreq-util/.github/FUNDING.yml +15 -0
- data/crates/wreq-util/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/crates/wreq-util/.github/ISSUE_TEMPLATE/custom.md +10 -0
- data/crates/wreq-util/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/crates/wreq-util/.github/dependabot.yml +22 -0
- data/crates/wreq-util/.github/workflows/ci.yml +82 -0
- data/crates/wreq-util/.github/workflows/release-plz.yml +52 -0
- data/crates/wreq-util/.gitignore +24 -0
- data/crates/wreq-util/CHANGELOG.md +74 -0
- data/crates/wreq-util/Cargo.toml +94 -0
- data/crates/wreq-util/LICENSE +201 -0
- data/crates/wreq-util/README.md +62 -0
- data/crates/wreq-util/examples/emulate.rs +39 -0
- data/crates/wreq-util/examples/tower_delay.rs +191 -0
- data/crates/wreq-util/release-plz.toml +2 -0
- data/crates/wreq-util/rustfmt.toml +5 -0
- data/crates/wreq-util/src/emulate/compress.rs +85 -0
- data/crates/wreq-util/src/emulate/macros.rs +370 -0
- data/crates/wreq-util/src/emulate/profile/chrome/header.rs +59 -0
- data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +65 -0
- data/crates/wreq-util/src/emulate/profile/chrome/tls.rs +153 -0
- data/crates/wreq-util/src/emulate/profile/chrome.rs +2028 -0
- data/crates/wreq-util/src/emulate/profile/firefox/header.rs +21 -0
- data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +113 -0
- data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +253 -0
- data/crates/wreq-util/src/emulate/profile/firefox.rs +518 -0
- data/crates/wreq-util/src/emulate/profile/okhttp.rs +241 -0
- data/crates/wreq-util/src/emulate/profile/opera/header.rs +30 -0
- data/crates/wreq-util/src/emulate/profile/opera/http2.rs +50 -0
- data/crates/wreq-util/src/emulate/profile/opera/tls.rs +97 -0
- data/crates/wreq-util/src/emulate/profile/opera.rs +299 -0
- data/crates/wreq-util/src/emulate/profile/safari/header.rs +59 -0
- data/crates/wreq-util/src/emulate/profile/safari/http2.rs +116 -0
- data/crates/wreq-util/src/emulate/profile/safari/tls.rs +177 -0
- data/crates/wreq-util/src/emulate/profile/safari.rs +222 -0
- data/crates/wreq-util/src/emulate/profile.rs +47 -0
- data/crates/wreq-util/src/emulate.rs +369 -0
- data/crates/wreq-util/src/lib.rs +14 -0
- data/crates/wreq-util/src/rand.rs +24 -0
- data/crates/wreq-util/src/tower/delay/future.rs +43 -0
- data/crates/wreq-util/src/tower/delay/layer.rs +201 -0
- data/crates/wreq-util/src/tower/delay/service.rs +190 -0
- data/crates/wreq-util/src/tower/delay.rs +98 -0
- data/crates/wreq-util/src/tower.rs +7 -0
- data/crates/wreq-util/tests/client.rs +51 -0
- data/crates/wreq-util/tests/emulate_chrome.rs +270 -0
- data/crates/wreq-util/tests/emulate_firefox.rs +92 -0
- data/crates/wreq-util/tests/emulate_okhttp.rs +46 -0
- data/crates/wreq-util/tests/emulate_opera.rs +113 -0
- data/crates/wreq-util/tests/emulate_safari.rs +151 -0
- data/crates/wreq-util/tests/support/mod.rs +55 -0
- data/crates/wreq-util/tests/support/server.rs +232 -0
- data/examples/emulate_request.rb +1 -1
- data/lib/wreq.rb +20 -18
- data/lib/wreq_ruby/body.rb +3 -0
- data/lib/wreq_ruby/client.rb +18 -18
- data/lib/wreq_ruby/cookie.rb +2 -2
- data/lib/wreq_ruby/emulate.rb +3 -1
- data/lib/wreq_ruby/header.rb +205 -114
- data/lib/wreq_ruby/response.rb +28 -3
- data/src/emulate.rs +1 -0
- data/src/error.rs +2 -6
- data/src/header/helper.rs +112 -0
- data/src/header.rs +198 -133
- data/test/header_test.rb +228 -192
- data/test/stream_test.rb +36 -0
- metadata +54 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
use super::*;
|
|
2
|
+
|
|
3
|
+
const CURVES: &str = join!(":", "X25519", "P-256", "P-384");
|
|
4
|
+
|
|
5
|
+
const SIGALGS_LIST: &str = join!(
|
|
6
|
+
":",
|
|
7
|
+
"ecdsa_secp256r1_sha256",
|
|
8
|
+
"rsa_pss_rsae_sha256",
|
|
9
|
+
"rsa_pkcs1_sha256",
|
|
10
|
+
"ecdsa_secp384r1_sha384",
|
|
11
|
+
"rsa_pss_rsae_sha384",
|
|
12
|
+
"rsa_pkcs1_sha384",
|
|
13
|
+
"rsa_pss_rsae_sha512",
|
|
14
|
+
"rsa_pkcs1_sha512",
|
|
15
|
+
"rsa_pkcs1_sha1"
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const CIPHER_LIST: &str = join!(
|
|
19
|
+
":",
|
|
20
|
+
"TLS_AES_128_GCM_SHA256",
|
|
21
|
+
"TLS_AES_256_GCM_SHA384",
|
|
22
|
+
"TLS_CHACHA20_POLY1305_SHA256",
|
|
23
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
24
|
+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
25
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
26
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
|
27
|
+
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
28
|
+
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
29
|
+
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
|
|
30
|
+
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
|
|
31
|
+
"TLS_RSA_WITH_AES_128_GCM_SHA256",
|
|
32
|
+
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
33
|
+
"TLS_RSA_WITH_AES_128_CBC_SHA",
|
|
34
|
+
"TLS_RSA_WITH_AES_256_CBC_SHA",
|
|
35
|
+
"TLS_RSA_WITH_3DES_EDE_CBC_SHA"
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
#[derive(TypedBuilder)]
|
|
39
|
+
struct OkHttpTlsConfig {
|
|
40
|
+
#[builder(default = CURVES)]
|
|
41
|
+
curves: &'static str,
|
|
42
|
+
|
|
43
|
+
#[builder(default = SIGALGS_LIST)]
|
|
44
|
+
sigalgs_list: &'static str,
|
|
45
|
+
|
|
46
|
+
cipher_list: &'static str,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
impl From<OkHttpTlsConfig> for TlsOptions {
|
|
50
|
+
fn from(val: OkHttpTlsConfig) -> Self {
|
|
51
|
+
TlsOptions::builder()
|
|
52
|
+
.enable_ocsp_stapling(true)
|
|
53
|
+
.curves_list(val.curves)
|
|
54
|
+
.sigalgs_list(val.sigalgs_list)
|
|
55
|
+
.cipher_list(val.cipher_list)
|
|
56
|
+
.min_tls_version(TlsVersion::TLS_1_2)
|
|
57
|
+
.max_tls_version(TlsVersion::TLS_1_3)
|
|
58
|
+
.aes_hw_override(true)
|
|
59
|
+
.build()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
macro_rules! mod_generator {
|
|
64
|
+
($mod_name:ident, $cipher:expr, $ua:expr) => {
|
|
65
|
+
pub(crate) mod $mod_name {
|
|
66
|
+
use super::*;
|
|
67
|
+
|
|
68
|
+
pub fn emulation(emulation: Emulation) -> wreq::Emulation {
|
|
69
|
+
build_emulation(stringify!($mod_name), emulation, $cipher, $ua)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
fn build_emulation(
|
|
76
|
+
group: &'static str,
|
|
77
|
+
emulation: Emulation,
|
|
78
|
+
cipher_list: &'static str,
|
|
79
|
+
user_agent: &'static str,
|
|
80
|
+
) -> wreq::Emulation {
|
|
81
|
+
let tls_options = OkHttpTlsConfig::builder()
|
|
82
|
+
.cipher_list(cipher_list)
|
|
83
|
+
.build()
|
|
84
|
+
.into();
|
|
85
|
+
|
|
86
|
+
let http2_options = emulation.http2.then(|| {
|
|
87
|
+
let settings_order = SettingsOrder::builder()
|
|
88
|
+
.extend([
|
|
89
|
+
SettingId::HeaderTableSize,
|
|
90
|
+
SettingId::EnablePush,
|
|
91
|
+
SettingId::MaxConcurrentStreams,
|
|
92
|
+
SettingId::InitialWindowSize,
|
|
93
|
+
SettingId::MaxFrameSize,
|
|
94
|
+
SettingId::MaxHeaderListSize,
|
|
95
|
+
SettingId::EnableConnectProtocol,
|
|
96
|
+
SettingId::NoRfc7540Priorities,
|
|
97
|
+
])
|
|
98
|
+
.build();
|
|
99
|
+
|
|
100
|
+
Http2Options::builder()
|
|
101
|
+
.initial_window_size(16777216)
|
|
102
|
+
.initial_connection_window_size(16777216)
|
|
103
|
+
.headers_pseudo_order(
|
|
104
|
+
PseudoOrder::builder()
|
|
105
|
+
.extend([
|
|
106
|
+
PseudoId::Method,
|
|
107
|
+
PseudoId::Path,
|
|
108
|
+
PseudoId::Authority,
|
|
109
|
+
PseudoId::Scheme,
|
|
110
|
+
])
|
|
111
|
+
.build(),
|
|
112
|
+
)
|
|
113
|
+
.settings_order(settings_order)
|
|
114
|
+
.build()
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
let headers = emulation.headers.then(|| {
|
|
118
|
+
let mut headers = HeaderMap::new();
|
|
119
|
+
headers.insert(ACCEPT, HeaderValue::from_static("*/*"));
|
|
120
|
+
headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9"));
|
|
121
|
+
headers.insert(USER_AGENT, HeaderValue::from_static(user_agent));
|
|
122
|
+
#[cfg(feature = "emulation-compression")]
|
|
123
|
+
headers.insert(ACCEPT_ENCODING, HeaderValue::from_static("gzip"));
|
|
124
|
+
headers
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
build_standard_emulation(group, tls_options, http2_options, headers)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
mod_generator!(
|
|
131
|
+
okhttp3_9,
|
|
132
|
+
join!(
|
|
133
|
+
":",
|
|
134
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
135
|
+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
136
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
137
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
|
138
|
+
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
139
|
+
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
140
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
|
|
141
|
+
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
|
|
142
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
|
|
143
|
+
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
|
|
144
|
+
"TLS_RSA_WITH_AES_128_GCM_SHA256",
|
|
145
|
+
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
146
|
+
"TLS_RSA_WITH_AES_128_CBC_SHA",
|
|
147
|
+
"TLS_RSA_WITH_AES_256_CBC_SHA",
|
|
148
|
+
"TLS_RSA_WITH_3DES_EDE_CBC_SHA"
|
|
149
|
+
),
|
|
150
|
+
"MaiMemo/4.4.50_639 okhttp/3.9 Android/5.0 Channel/WanDouJia Device/alps+M8+Emulator (armeabi-v7a) Screen/4.44 Resolution/480x800 DId/aa6cde19def3806806d5374c4e5fd617 RAM/0.94 ROM/4.91 Theme/Day"
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
mod_generator!(
|
|
154
|
+
okhttp3_11,
|
|
155
|
+
join!(
|
|
156
|
+
":",
|
|
157
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
158
|
+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
159
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
160
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
|
161
|
+
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
162
|
+
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
163
|
+
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
|
|
164
|
+
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
|
|
165
|
+
"TLS_RSA_WITH_AES_128_GCM_SHA256",
|
|
166
|
+
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
167
|
+
"TLS_RSA_WITH_AES_128_CBC_SHA",
|
|
168
|
+
"TLS_RSA_WITH_AES_256_CBC_SHA",
|
|
169
|
+
"TLS_RSA_WITH_3DES_EDE_CBC_SHA"
|
|
170
|
+
),
|
|
171
|
+
"NRC Audio/2.0.6 (nl.nrc.audio; build:36; Android 12; Sdk:31; Manufacturer:motorola; Model: moto g72) OkHttp/3.11.0"
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
mod_generator!(
|
|
175
|
+
okhttp3_13,
|
|
176
|
+
join!(
|
|
177
|
+
":",
|
|
178
|
+
"TLS_AES_128_GCM_SHA256",
|
|
179
|
+
"TLS_AES_256_GCM_SHA384",
|
|
180
|
+
"TLS_CHACHA20_POLY1305_SHA256",
|
|
181
|
+
"TLS_AES_128_CCM_SHA256",
|
|
182
|
+
"TLS_AES_256_CCM_8_SHA256",
|
|
183
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
184
|
+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
185
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
186
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
|
187
|
+
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
188
|
+
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
189
|
+
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
|
|
190
|
+
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
|
|
191
|
+
"TLS_RSA_WITH_AES_128_GCM_SHA256",
|
|
192
|
+
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
193
|
+
"TLS_RSA_WITH_AES_128_CBC_SHA",
|
|
194
|
+
"TLS_RSA_WITH_AES_256_CBC_SHA",
|
|
195
|
+
"TLS_RSA_WITH_3DES_EDE_CBC_SHA"
|
|
196
|
+
),
|
|
197
|
+
"GM-Android/6.112.2 (240590300; M:Google Pixel 7a; O:34; D:2b045e03986fa6dc) ObsoleteUrlFactory/1.0 OkHttp/3.13.0"
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
mod_generator!(
|
|
201
|
+
okhttp3_14,
|
|
202
|
+
CIPHER_LIST,
|
|
203
|
+
"DS podcast/2.0.1 (be.standaard.audio; build:9; Android 11; Sdk:30; Manufacturer:samsung; Model: SM-A405FN) OkHttp/3.14.0"
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
mod_generator!(
|
|
207
|
+
okhttp4_10,
|
|
208
|
+
CIPHER_LIST,
|
|
209
|
+
"GM-Android/6.112.2 (240590300; M:samsung SM-G781U1; O:33; D:edb34792871638d8) ObsoleteUrlFactory/1.0 OkHttp/4.10.0"
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
mod_generator!(
|
|
213
|
+
okhttp4_9,
|
|
214
|
+
join!(
|
|
215
|
+
":",
|
|
216
|
+
"TLS_AES_128_GCM_SHA256",
|
|
217
|
+
"TLS_AES_256_GCM_SHA384",
|
|
218
|
+
"TLS_CHACHA20_POLY1305_SHA256",
|
|
219
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
220
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
221
|
+
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
222
|
+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
223
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
|
224
|
+
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
225
|
+
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
|
|
226
|
+
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
|
|
227
|
+
"TLS_RSA_WITH_AES_128_GCM_SHA256",
|
|
228
|
+
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
229
|
+
"TLS_RSA_WITH_AES_128_CBC_SHA",
|
|
230
|
+
"TLS_RSA_WITH_AES_256_CBC_SHA"
|
|
231
|
+
),
|
|
232
|
+
"GM-Android/6.111.1 (240460200; M:motorola moto g power (2021); O:30; D:76ba9f6628d198c8) ObsoleteUrlFactory/1.0 OkHttp/4.9"
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
mod_generator!(okhttp4_12, CIPHER_LIST, "okhttp/4.12.0");
|
|
236
|
+
|
|
237
|
+
mod_generator!(
|
|
238
|
+
okhttp5,
|
|
239
|
+
CIPHER_LIST,
|
|
240
|
+
"NRC Audio/2.0.6 (nl.nrc.audio; build:36; Android 14; Sdk:34; Manufacturer:OnePlus; Model: CPH2609) OkHttp/5.0.0-alpha2"
|
|
241
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
use super::*;
|
|
2
|
+
|
|
3
|
+
#[inline]
|
|
4
|
+
pub fn header_initializer_with_zstd_priority(
|
|
5
|
+
sec_ch_ua: &'static str,
|
|
6
|
+
ua: &'static str,
|
|
7
|
+
emulation_os: Platform,
|
|
8
|
+
) -> HeaderMap {
|
|
9
|
+
let mut headers = HeaderMap::new();
|
|
10
|
+
header_chrome_sec_ch_ua!(
|
|
11
|
+
headers,
|
|
12
|
+
sec_ch_ua,
|
|
13
|
+
emulation_os.platform(),
|
|
14
|
+
emulation_os.is_mobile()
|
|
15
|
+
);
|
|
16
|
+
header_chrome_ua!(headers, ua);
|
|
17
|
+
|
|
18
|
+
headers.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"));
|
|
19
|
+
#[cfg(feature = "emulation-compression")]
|
|
20
|
+
headers.insert(
|
|
21
|
+
ACCEPT_ENCODING,
|
|
22
|
+
HeaderValue::from_static("gzip, deflate, br, zstd"),
|
|
23
|
+
);
|
|
24
|
+
headers.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9"));
|
|
25
|
+
headers.insert(
|
|
26
|
+
HeaderName::from_static("priority"),
|
|
27
|
+
HeaderValue::from_static("u=0, i"),
|
|
28
|
+
);
|
|
29
|
+
headers
|
|
30
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
macro_rules! headers_stream_dependency {
|
|
2
|
+
() => {
|
|
3
|
+
StreamDependency::new(StreamId::zero(), 219, true)
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
macro_rules! pseudo_order {
|
|
8
|
+
() => {
|
|
9
|
+
PseudoOrder::builder()
|
|
10
|
+
.extend([
|
|
11
|
+
PseudoId::Method,
|
|
12
|
+
PseudoId::Authority,
|
|
13
|
+
PseudoId::Scheme,
|
|
14
|
+
PseudoId::Path,
|
|
15
|
+
])
|
|
16
|
+
.build()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
macro_rules! settings_order {
|
|
21
|
+
() => {
|
|
22
|
+
SettingsOrder::builder()
|
|
23
|
+
.extend([
|
|
24
|
+
SettingId::HeaderTableSize,
|
|
25
|
+
SettingId::EnablePush,
|
|
26
|
+
SettingId::MaxConcurrentStreams,
|
|
27
|
+
SettingId::InitialWindowSize,
|
|
28
|
+
SettingId::MaxFrameSize,
|
|
29
|
+
SettingId::MaxHeaderListSize,
|
|
30
|
+
SettingId::EnableConnectProtocol,
|
|
31
|
+
SettingId::NoRfc7540Priorities,
|
|
32
|
+
])
|
|
33
|
+
.build()
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
macro_rules! http2_options {
|
|
38
|
+
() => {
|
|
39
|
+
Http2Options::builder()
|
|
40
|
+
.initial_window_size(6291456)
|
|
41
|
+
.initial_connection_window_size(15728640)
|
|
42
|
+
.max_header_list_size(262144)
|
|
43
|
+
.header_table_size(65536)
|
|
44
|
+
.enable_push(false)
|
|
45
|
+
.headers_stream_dependency(headers_stream_dependency!())
|
|
46
|
+
.headers_pseudo_order(pseudo_order!())
|
|
47
|
+
.settings_order(settings_order!())
|
|
48
|
+
.build()
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
use super::*;
|
|
2
|
+
|
|
3
|
+
macro_rules! tls_options {
|
|
4
|
+
($curves:expr) => {
|
|
5
|
+
OperaTlsConfig::builder()
|
|
6
|
+
.curves($curves)
|
|
7
|
+
.permute_extensions(true)
|
|
8
|
+
.pre_shared_key(true)
|
|
9
|
+
.enable_ech_grease(true)
|
|
10
|
+
.build()
|
|
11
|
+
.into()
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
pub const CURVES: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384");
|
|
16
|
+
|
|
17
|
+
pub const CIPHER_LIST: &str = join!(
|
|
18
|
+
":",
|
|
19
|
+
"TLS_AES_128_GCM_SHA256",
|
|
20
|
+
"TLS_AES_256_GCM_SHA384",
|
|
21
|
+
"TLS_CHACHA20_POLY1305_SHA256",
|
|
22
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
23
|
+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
24
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
|
25
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
|
26
|
+
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
27
|
+
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
|
|
28
|
+
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
|
|
29
|
+
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
|
|
30
|
+
"TLS_RSA_WITH_AES_128_GCM_SHA256",
|
|
31
|
+
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
32
|
+
"TLS_RSA_WITH_AES_128_CBC_SHA",
|
|
33
|
+
"TLS_RSA_WITH_AES_256_CBC_SHA"
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
pub const SIGALGS_LIST: &str = join!(
|
|
37
|
+
":",
|
|
38
|
+
"ecdsa_secp256r1_sha256",
|
|
39
|
+
"rsa_pss_rsae_sha256",
|
|
40
|
+
"rsa_pkcs1_sha256",
|
|
41
|
+
"ecdsa_secp384r1_sha384",
|
|
42
|
+
"rsa_pss_rsae_sha384",
|
|
43
|
+
"rsa_pkcs1_sha384",
|
|
44
|
+
"rsa_pss_rsae_sha512",
|
|
45
|
+
"rsa_pkcs1_sha512"
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&BrotliCompressor];
|
|
49
|
+
|
|
50
|
+
#[derive(TypedBuilder)]
|
|
51
|
+
pub struct OperaTlsConfig {
|
|
52
|
+
#[builder(default = CURVES)]
|
|
53
|
+
curves: &'static str,
|
|
54
|
+
|
|
55
|
+
#[builder(default = SIGALGS_LIST)]
|
|
56
|
+
sigalgs_list: &'static str,
|
|
57
|
+
|
|
58
|
+
#[builder(default = CIPHER_LIST)]
|
|
59
|
+
cipher_list: &'static str,
|
|
60
|
+
|
|
61
|
+
#[builder(default = AlpsProtocol::HTTP2, setter(into))]
|
|
62
|
+
alps_protos: AlpsProtocol,
|
|
63
|
+
|
|
64
|
+
#[builder(default = false)]
|
|
65
|
+
alps_use_new_codepoint: bool,
|
|
66
|
+
|
|
67
|
+
#[builder(default = false, setter(into))]
|
|
68
|
+
enable_ech_grease: bool,
|
|
69
|
+
|
|
70
|
+
#[builder(default = false, setter(into))]
|
|
71
|
+
permute_extensions: bool,
|
|
72
|
+
|
|
73
|
+
#[builder(default = false, setter(into))]
|
|
74
|
+
pre_shared_key: bool,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
impl From<OperaTlsConfig> for TlsOptions {
|
|
78
|
+
fn from(val: OperaTlsConfig) -> Self {
|
|
79
|
+
TlsOptions::builder()
|
|
80
|
+
.grease_enabled(true)
|
|
81
|
+
.enable_ocsp_stapling(true)
|
|
82
|
+
.enable_signed_cert_timestamps(true)
|
|
83
|
+
.curves_list(val.curves)
|
|
84
|
+
.sigalgs_list(val.sigalgs_list)
|
|
85
|
+
.cipher_list(val.cipher_list)
|
|
86
|
+
.min_tls_version(TlsVersion::TLS_1_2)
|
|
87
|
+
.max_tls_version(TlsVersion::TLS_1_3)
|
|
88
|
+
.permute_extensions(val.permute_extensions)
|
|
89
|
+
.pre_shared_key(val.pre_shared_key)
|
|
90
|
+
.enable_ech_grease(val.enable_ech_grease)
|
|
91
|
+
.alps_protocols([val.alps_protos])
|
|
92
|
+
.alps_use_new_codepoint(val.alps_use_new_codepoint)
|
|
93
|
+
.aes_hw_override(true)
|
|
94
|
+
.certificate_compressors(CERTIFICATE_COMPRESSORS)
|
|
95
|
+
.build()
|
|
96
|
+
}
|
|
97
|
+
}
|