rnet 3.0.0rc6__cp311-abi3-win_arm64.whl → 3.0.0rc8__cp311-abi3-win_arm64.whl
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.
Potentially problematic release.
This version of rnet might be problematic. Click here for more details.
- rnet/__init__.py +4 -0
- rnet/__init__.pyi +262 -97
- rnet/emulation.py +8 -2
- rnet/http1.py +67 -0
- rnet/http2.py +352 -0
- rnet/rnet.pyd +0 -0
- rnet/tls.py +271 -3
- {rnet-3.0.0rc6.dist-info → rnet-3.0.0rc8.dist-info}/METADATA +22 -6
- rnet-3.0.0rc8.dist-info/RECORD +16 -0
- rnet-3.0.0rc6.dist-info/RECORD +0 -14
- {rnet-3.0.0rc6.dist-info → rnet-3.0.0rc8.dist-info}/WHEEL +0 -0
- {rnet-3.0.0rc6.dist-info → rnet-3.0.0rc8.dist-info}/licenses/LICENSE +0 -0
rnet/http2.py
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"""
|
|
2
|
+
HTTP/2 connection configuration.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import datetime
|
|
6
|
+
from enum import Enum, auto
|
|
7
|
+
from typing import ClassVar, Self, TypedDict, NotRequired, Unpack
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"StreamId",
|
|
11
|
+
"StreamDependency",
|
|
12
|
+
"Priority",
|
|
13
|
+
"Priorities",
|
|
14
|
+
"PseudoId",
|
|
15
|
+
"PseudoOrder",
|
|
16
|
+
"SettingId",
|
|
17
|
+
"SettingsOrder",
|
|
18
|
+
"Params",
|
|
19
|
+
"Http2Options",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class PseudoId(Enum):
|
|
24
|
+
"""
|
|
25
|
+
Represents the order of HTTP/2 pseudo-header fields in the header block.
|
|
26
|
+
|
|
27
|
+
HTTP/2 pseudo-header fields are a set of predefined header fields that start with ':'.
|
|
28
|
+
The order of these fields in a header block is significant. This enum defines the
|
|
29
|
+
possible pseudo-header fields and their standard order according to RFC 7540.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
METHOD = auto()
|
|
33
|
+
SCHEME = auto()
|
|
34
|
+
AUTHORITY = auto()
|
|
35
|
+
PATH = auto()
|
|
36
|
+
PROTOCOL = auto()
|
|
37
|
+
STATUS = auto()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class SettingId(Enum):
|
|
41
|
+
"""
|
|
42
|
+
An enum that lists all valid settings that can be sent in a SETTINGS frame.
|
|
43
|
+
|
|
44
|
+
Each setting has a value that is a 32 bit unsigned integer (6.5.1.).
|
|
45
|
+
|
|
46
|
+
See <https://datatracker.ietf.org/doc/html/rfc9113#name-defined-settings>.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
HEADER_TABLE_SIZE = auto()
|
|
50
|
+
"""
|
|
51
|
+
This setting allows the sender to inform the remote endpoint
|
|
52
|
+
of the maximum size of the compression table used to decode field blocks,
|
|
53
|
+
in units of octets. The encoder can select any size equal to or less than
|
|
54
|
+
this value by using signaling specific to the compression format inside
|
|
55
|
+
a field block (see [COMPRESSION]). The initial value is 4,096 octets.
|
|
56
|
+
|
|
57
|
+
[COMPRESSION]: <https://datatracker.ietf.org/doc/html/rfc7541>
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
ENABLE_PUSH = auto()
|
|
61
|
+
"""
|
|
62
|
+
Enables or disables server push.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
MAX_CONCURRENT_STREAMS = auto()
|
|
66
|
+
"""
|
|
67
|
+
Specifies the maximum number of concurrent streams.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
INITIAL_WINDOW_SIZE = auto()
|
|
71
|
+
"""
|
|
72
|
+
Sets the initial stream-level flow control window size.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
MAX_FRAME_SIZE = auto()
|
|
76
|
+
"""
|
|
77
|
+
Indicates the largest acceptable frame payload size.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
MAX_HEADER_LIST_SIZE = auto()
|
|
81
|
+
"""
|
|
82
|
+
Advises the peer of the max field section size.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
ENABLE_CONNECT_PROTOCOL = auto()
|
|
86
|
+
"""
|
|
87
|
+
Enables support for the Extended CONNECT protocol.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
NO_RFC7540_PRIORITIES = auto()
|
|
91
|
+
"""
|
|
92
|
+
Disable RFC 7540 Stream Priorities.
|
|
93
|
+
[RFC 9218]: <https://www.rfc-editor.org/rfc/rfc9218.html#section-2.1>
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class StreamId:
|
|
98
|
+
"""
|
|
99
|
+
A stream identifier, as described in [Section 5.1.1] of RFC 7540.
|
|
100
|
+
|
|
101
|
+
Streams are identified with an unsigned 31-bit integer. Streams
|
|
102
|
+
initiated by a client MUST use odd-numbered stream identifiers; those
|
|
103
|
+
initiated by the server MUST use even-numbered stream identifiers. A
|
|
104
|
+
stream identifier of zero (0x0) is used for connection control
|
|
105
|
+
messages; the stream identifier of zero cannot be used to establish a
|
|
106
|
+
new stream.
|
|
107
|
+
|
|
108
|
+
[Section 5.1.1]: https://tools.ietf.org/html/rfc7540#section-5.1.1
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
ZERO: ClassVar[Self]
|
|
112
|
+
"""Stream ID 0."""
|
|
113
|
+
|
|
114
|
+
MAX: ClassVar[Self]
|
|
115
|
+
"""The maximum allowed stream ID."""
|
|
116
|
+
|
|
117
|
+
def __init__(self, src: int) -> None:
|
|
118
|
+
"""
|
|
119
|
+
Create a new StreamId.
|
|
120
|
+
"""
|
|
121
|
+
...
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class StreamDependency:
|
|
125
|
+
"""
|
|
126
|
+
Represents a stream dependency in HTTP/2 priority frames.
|
|
127
|
+
|
|
128
|
+
A stream dependency consists of three components:
|
|
129
|
+
* A stream identifier that the stream depends on
|
|
130
|
+
* A weight value between 0 and 255 (representing 1-256 in the protocol)
|
|
131
|
+
* An exclusive flag indicating whether this is an exclusive dependency
|
|
132
|
+
|
|
133
|
+
# Stream Dependencies
|
|
134
|
+
|
|
135
|
+
In HTTP/2, stream dependencies form a dependency tree where each stream
|
|
136
|
+
can depend on another stream. This creates a priority hierarchy that helps
|
|
137
|
+
determine the relative order in which streams should be processed.
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
def __init__(
|
|
141
|
+
self, dependency_id: StreamId, weight: int, is_exclusive: bool
|
|
142
|
+
) -> None:
|
|
143
|
+
"""
|
|
144
|
+
Create a new StreamDependency.
|
|
145
|
+
"""
|
|
146
|
+
...
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class Priority:
|
|
150
|
+
"""
|
|
151
|
+
Represents an HTTP/2 PRIORITY frame (type=0x2).
|
|
152
|
+
|
|
153
|
+
The PRIORITY frame specifies the sender-advised priority of a stream,
|
|
154
|
+
as described in RFC 7540 Section 5.3. It can be sent in any stream state,
|
|
155
|
+
including idle or closed streams.
|
|
156
|
+
|
|
157
|
+
A PRIORITY frame consists of:
|
|
158
|
+
* The stream identifier whose priority is being set
|
|
159
|
+
* A StreamDependency object describing the dependency and weight
|
|
160
|
+
|
|
161
|
+
[Section 5.3]: https://tools.ietf.org/html/rfc7540#section-5.3
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
def __init__(self, stream_id: StreamId, dependency: StreamDependency) -> None:
|
|
165
|
+
"""
|
|
166
|
+
Create a new Priority frame description.
|
|
167
|
+
"""
|
|
168
|
+
...
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class Priorities:
|
|
172
|
+
"""
|
|
173
|
+
A collection of HTTP/2 PRIORITY frames.
|
|
174
|
+
|
|
175
|
+
The Priorities class maintains an ordered list of Priority frames,
|
|
176
|
+
which can be used to represent and manage the stream dependency tree
|
|
177
|
+
in HTTP/2. This is useful for pre-configuring stream priorities or
|
|
178
|
+
sending multiple PRIORITY frames at once during connection setup or
|
|
179
|
+
stream reprioritization.
|
|
180
|
+
"""
|
|
181
|
+
|
|
182
|
+
def __init__(self, *priority: Priority) -> None:
|
|
183
|
+
"""
|
|
184
|
+
Create a new Priorities instance.
|
|
185
|
+
"""
|
|
186
|
+
...
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class PseudoOrder:
|
|
190
|
+
"""
|
|
191
|
+
Represents the order of HTTP/2 pseudo-header fields in the header block.
|
|
192
|
+
|
|
193
|
+
The PseudoOrder class maintains a list of PseudoId values that define
|
|
194
|
+
the order in which pseudo-header fields should appear in an HTTP/2
|
|
195
|
+
HEADERS frame. This is important because the order of pseudo-headers
|
|
196
|
+
is significant and must follow specific rules as defined in RFC 7540.
|
|
197
|
+
"""
|
|
198
|
+
|
|
199
|
+
def __init__(self, *pseudo_id: PseudoId) -> None:
|
|
200
|
+
"""
|
|
201
|
+
Create a new PseudoOrder instance.
|
|
202
|
+
"""
|
|
203
|
+
...
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
class SettingsOrder:
|
|
207
|
+
"""
|
|
208
|
+
Represents the order of HTTP/2 settings parameters in the SETTINGS frame.
|
|
209
|
+
|
|
210
|
+
The SettingsOrder class maintains a list of SettingId values that define
|
|
211
|
+
the order in which settings parameters should appear in an HTTP/2
|
|
212
|
+
SETTINGS frame. While the order of settings is not strictly enforced
|
|
213
|
+
by the protocol, having a consistent order can help with readability
|
|
214
|
+
and debugging.
|
|
215
|
+
"""
|
|
216
|
+
|
|
217
|
+
def __init__(self, *setting_id: SettingId) -> None:
|
|
218
|
+
"""
|
|
219
|
+
Create a new SettingsOrder instance.
|
|
220
|
+
"""
|
|
221
|
+
...
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class Params(TypedDict):
|
|
225
|
+
"""
|
|
226
|
+
All parameters for HTTP/2 connections.
|
|
227
|
+
"""
|
|
228
|
+
|
|
229
|
+
initial_window_size: NotRequired[int]
|
|
230
|
+
"""
|
|
231
|
+
Initial window size for HTTP/2 streams.
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
initial_connection_window_size: NotRequired[int]
|
|
235
|
+
"""
|
|
236
|
+
Initial connection-level window size.
|
|
237
|
+
"""
|
|
238
|
+
|
|
239
|
+
initial_max_send_streams: NotRequired[int]
|
|
240
|
+
"""
|
|
241
|
+
Initial maximum number of send streams.
|
|
242
|
+
"""
|
|
243
|
+
|
|
244
|
+
initial_stream_id: NotRequired[int]
|
|
245
|
+
"""
|
|
246
|
+
Initial stream ID for the connection.
|
|
247
|
+
"""
|
|
248
|
+
|
|
249
|
+
adaptive_window: NotRequired[bool]
|
|
250
|
+
"""
|
|
251
|
+
Whether to use adaptive flow control.
|
|
252
|
+
"""
|
|
253
|
+
|
|
254
|
+
max_frame_size: NotRequired[int]
|
|
255
|
+
"""
|
|
256
|
+
Maximum frame size to use for HTTP/2.
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
max_header_list_size: NotRequired[int]
|
|
260
|
+
"""
|
|
261
|
+
Maximum size of the header list.
|
|
262
|
+
"""
|
|
263
|
+
|
|
264
|
+
header_table_size: NotRequired[int]
|
|
265
|
+
"""
|
|
266
|
+
Header table size for HPACK compression.
|
|
267
|
+
"""
|
|
268
|
+
|
|
269
|
+
max_concurrent_streams: NotRequired[int]
|
|
270
|
+
"""
|
|
271
|
+
Maximum concurrent streams from remote peer.
|
|
272
|
+
"""
|
|
273
|
+
|
|
274
|
+
keep_alive_interval: NotRequired[datetime.timedelta]
|
|
275
|
+
"""
|
|
276
|
+
Interval for HTTP/2 keep-alive ping frames.
|
|
277
|
+
"""
|
|
278
|
+
|
|
279
|
+
keep_alive_timeout: NotRequired[datetime.timedelta]
|
|
280
|
+
"""
|
|
281
|
+
Timeout for keep-alive ping acknowledgements.
|
|
282
|
+
"""
|
|
283
|
+
|
|
284
|
+
keep_alive_while_idle: NotRequired[bool]
|
|
285
|
+
"""
|
|
286
|
+
Whether keep-alive applies while idle.
|
|
287
|
+
"""
|
|
288
|
+
|
|
289
|
+
enable_push: NotRequired[bool]
|
|
290
|
+
"""
|
|
291
|
+
Whether to enable push promises.
|
|
292
|
+
"""
|
|
293
|
+
|
|
294
|
+
enable_connect_protocol: NotRequired[bool]
|
|
295
|
+
"""
|
|
296
|
+
Whether to enable the CONNECT protocol.
|
|
297
|
+
"""
|
|
298
|
+
|
|
299
|
+
no_rfc7540_priorities: NotRequired[bool]
|
|
300
|
+
"""
|
|
301
|
+
Whether to disable RFC 7540 Stream Priorities.
|
|
302
|
+
"""
|
|
303
|
+
|
|
304
|
+
max_concurrent_reset_streams: NotRequired[int]
|
|
305
|
+
"""
|
|
306
|
+
Max concurrent locally reset streams.
|
|
307
|
+
"""
|
|
308
|
+
|
|
309
|
+
max_send_buf_size: NotRequired[int]
|
|
310
|
+
"""
|
|
311
|
+
Maximum send buffer size for streams.
|
|
312
|
+
"""
|
|
313
|
+
|
|
314
|
+
max_pending_accept_reset_streams: NotRequired[int]
|
|
315
|
+
"""
|
|
316
|
+
Max pending accept reset streams.
|
|
317
|
+
"""
|
|
318
|
+
|
|
319
|
+
headers_stream_dependency: NotRequired[StreamDependency]
|
|
320
|
+
"""
|
|
321
|
+
Stream dependency for outgoing HEADERS.
|
|
322
|
+
"""
|
|
323
|
+
|
|
324
|
+
headers_pseudo_order: NotRequired[PseudoOrder]
|
|
325
|
+
"""
|
|
326
|
+
Order of pseudo-header fields in HEADERS.
|
|
327
|
+
"""
|
|
328
|
+
|
|
329
|
+
settings_order: NotRequired[SettingsOrder]
|
|
330
|
+
"""
|
|
331
|
+
Order of settings parameters in SETTINGS frame.
|
|
332
|
+
"""
|
|
333
|
+
|
|
334
|
+
priorities: NotRequired[Priorities]
|
|
335
|
+
"""
|
|
336
|
+
List of PRIORITY frames to send after connection.
|
|
337
|
+
"""
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
class Http2Options:
|
|
341
|
+
"""
|
|
342
|
+
Configuration for an HTTP/2 connection.
|
|
343
|
+
|
|
344
|
+
This struct defines various parameters to fine-tune the behavior of an HTTP/2 connection,
|
|
345
|
+
including stream management, window sizes, frame limits, and header config.
|
|
346
|
+
"""
|
|
347
|
+
|
|
348
|
+
def __init__(self, **kwargs: Unpack[Params]) -> None:
|
|
349
|
+
"""
|
|
350
|
+
Create a new Http2Options instance.
|
|
351
|
+
"""
|
|
352
|
+
...
|
rnet/rnet.pyd
CHANGED
|
Binary file
|
rnet/tls.py
CHANGED
|
@@ -8,9 +8,20 @@ These types are typically used to configure client-side TLS authentication and c
|
|
|
8
8
|
|
|
9
9
|
from enum import Enum, auto
|
|
10
10
|
from pathlib import Path
|
|
11
|
-
from typing import List
|
|
12
|
-
|
|
13
|
-
__all__ = [
|
|
11
|
+
from typing import List, NotRequired, TypedDict, Unpack
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"TlsVersion",
|
|
15
|
+
"Identity",
|
|
16
|
+
"CertStore",
|
|
17
|
+
"KeyLog",
|
|
18
|
+
"AlpnProtocol",
|
|
19
|
+
"AlpsProtocol",
|
|
20
|
+
"CertificateCompressionAlgorithm",
|
|
21
|
+
"ExtensionType",
|
|
22
|
+
"TlsOptions",
|
|
23
|
+
"Params",
|
|
24
|
+
]
|
|
14
25
|
|
|
15
26
|
|
|
16
27
|
class TlsVersion(Enum):
|
|
@@ -24,6 +35,74 @@ class TlsVersion(Enum):
|
|
|
24
35
|
TLS_1_3 = auto()
|
|
25
36
|
|
|
26
37
|
|
|
38
|
+
class AlpnProtocol(Enum):
|
|
39
|
+
"""
|
|
40
|
+
A TLS ALPN protocol.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
HTTP1 = auto()
|
|
44
|
+
HTTP2 = auto()
|
|
45
|
+
HTTP3 = auto()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class AlpsProtocol(Enum):
|
|
49
|
+
"""
|
|
50
|
+
Application-layer protocol settings for HTTP/1.1 and HTTP/2.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
HTTP1 = auto()
|
|
54
|
+
HTTP2 = auto()
|
|
55
|
+
HTTP3 = auto()
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class CertificateCompressionAlgorithm(Enum):
|
|
59
|
+
"""
|
|
60
|
+
IANA assigned identifier of compression algorithm.
|
|
61
|
+
See https://www.rfc-editor.org/rfc/rfc8879.html#name-compression-algorithms
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
ZLIB = auto()
|
|
65
|
+
BROTLI = auto()
|
|
66
|
+
ZSTD = auto()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ExtensionType(Enum):
|
|
70
|
+
"""
|
|
71
|
+
A TLS extension type.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
SERVER_NAME = auto()
|
|
75
|
+
STATUS_REQUEST = auto()
|
|
76
|
+
EC_POINT_FORMATS = auto()
|
|
77
|
+
SIGNATURE_ALGORITHMS = auto()
|
|
78
|
+
SRTP = auto()
|
|
79
|
+
APPLICATION_LAYER_PROTOCOL_NEGOTIATION = auto()
|
|
80
|
+
PADDING = auto()
|
|
81
|
+
EXTENDED_MASTER_SECRET = auto()
|
|
82
|
+
QUIC_TRANSPORT_PARAMETERS_LEGACY = auto()
|
|
83
|
+
QUIC_TRANSPORT_PARAMETERS_STANDARD = auto()
|
|
84
|
+
CERT_COMPRESSION = auto()
|
|
85
|
+
SESSION_TICKET = auto()
|
|
86
|
+
SUPPORTED_GROUPS = auto()
|
|
87
|
+
PRE_SHARED_KEY = auto()
|
|
88
|
+
EARLY_DATA = auto()
|
|
89
|
+
SUPPORTED_VERSIONS = auto()
|
|
90
|
+
COOKIE = auto()
|
|
91
|
+
PSK_KEY_EXCHANGE_MODES = auto()
|
|
92
|
+
CERTIFICATE_AUTHORITIES = auto()
|
|
93
|
+
SIGNATURE_ALGORITHMS_CERT = auto()
|
|
94
|
+
KEY_SHARE = auto()
|
|
95
|
+
RENEGOTIATE = auto()
|
|
96
|
+
DELEGATED_CREDENTIAL = auto()
|
|
97
|
+
APPLICATION_SETTINGS = auto()
|
|
98
|
+
APPLICATION_SETTINGS_NEW = auto()
|
|
99
|
+
ENCRYPTED_CLIENT_HELLO = auto()
|
|
100
|
+
CERTIFICATE_TIMESTAMP = auto()
|
|
101
|
+
NEXT_PROTO_NEG = auto()
|
|
102
|
+
CHANNEL_ID = auto()
|
|
103
|
+
RECORD_SIZE_LIMIT = auto()
|
|
104
|
+
|
|
105
|
+
|
|
27
106
|
class Identity:
|
|
28
107
|
"""
|
|
29
108
|
Represents a private key and X509 cert as a client certificate.
|
|
@@ -149,3 +228,192 @@ class KeyLog:
|
|
|
149
228
|
path: The file path to log TLS keys to.
|
|
150
229
|
"""
|
|
151
230
|
...
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class Params(TypedDict):
|
|
234
|
+
"""
|
|
235
|
+
All parameters for TLS connections.
|
|
236
|
+
"""
|
|
237
|
+
|
|
238
|
+
alpn_protocols: NotRequired[List[AlpnProtocol]]
|
|
239
|
+
"""
|
|
240
|
+
Application-Layer Protocol Negotiation (RFC 7301).
|
|
241
|
+
|
|
242
|
+
Specifies which application protocols (e.g., HTTP/2, HTTP/1.1) may be negotiated
|
|
243
|
+
over a single TLS connection.
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
alps_protocols: NotRequired[List[AlpsProtocol]]
|
|
247
|
+
"""
|
|
248
|
+
Application-Layer Protocol Settings (ALPS).
|
|
249
|
+
|
|
250
|
+
Enables exchanging application-layer settings during the handshake
|
|
251
|
+
for protocols negotiated via ALPN.
|
|
252
|
+
"""
|
|
253
|
+
|
|
254
|
+
alps_use_new_codepoint: NotRequired[bool]
|
|
255
|
+
"""
|
|
256
|
+
Whether to use an alternative ALPS codepoint for compatibility.
|
|
257
|
+
|
|
258
|
+
Useful when larger ALPS payloads are required.
|
|
259
|
+
"""
|
|
260
|
+
|
|
261
|
+
session_ticket: NotRequired[bool]
|
|
262
|
+
"""
|
|
263
|
+
Enables TLS Session Tickets (RFC 5077).
|
|
264
|
+
|
|
265
|
+
Allows session resumption without requiring server-side state.
|
|
266
|
+
"""
|
|
267
|
+
|
|
268
|
+
min_tls_version: NotRequired[TlsVersion]
|
|
269
|
+
"""
|
|
270
|
+
Minimum TLS version allowed for the connection.
|
|
271
|
+
"""
|
|
272
|
+
|
|
273
|
+
max_tls_version: NotRequired[TlsVersion]
|
|
274
|
+
"""
|
|
275
|
+
Maximum TLS version allowed for the connection.
|
|
276
|
+
"""
|
|
277
|
+
|
|
278
|
+
pre_shared_key: NotRequired[bool]
|
|
279
|
+
"""
|
|
280
|
+
Enables Pre-Shared Key (PSK) cipher suites (RFC 4279).
|
|
281
|
+
|
|
282
|
+
Authentication relies on out-of-band pre-shared keys instead of certificates.
|
|
283
|
+
"""
|
|
284
|
+
|
|
285
|
+
enable_ech_grease: NotRequired[bool]
|
|
286
|
+
"""
|
|
287
|
+
Controls whether to send a GREASE Encrypted ClientHello (ECH) extension
|
|
288
|
+
when no supported ECH configuration is available.
|
|
289
|
+
|
|
290
|
+
GREASE prevents protocol ossification by sending unknown extensions.
|
|
291
|
+
"""
|
|
292
|
+
|
|
293
|
+
permute_extensions: NotRequired[bool]
|
|
294
|
+
"""
|
|
295
|
+
Controls whether ClientHello extensions should be permuted.
|
|
296
|
+
"""
|
|
297
|
+
|
|
298
|
+
grease_enabled: NotRequired[bool]
|
|
299
|
+
"""
|
|
300
|
+
Controls whether GREASE extensions (RFC 8701) are enabled in general.
|
|
301
|
+
"""
|
|
302
|
+
|
|
303
|
+
enable_ocsp_stapling: NotRequired[bool]
|
|
304
|
+
"""
|
|
305
|
+
Enables OCSP stapling for the connection.
|
|
306
|
+
"""
|
|
307
|
+
|
|
308
|
+
enable_signed_cert_timestamps: NotRequired[bool]
|
|
309
|
+
"""
|
|
310
|
+
Enables Signed Certificate Timestamps (SCT).
|
|
311
|
+
"""
|
|
312
|
+
|
|
313
|
+
record_size_limit: NotRequired[int]
|
|
314
|
+
"""
|
|
315
|
+
Sets the maximum TLS record size.
|
|
316
|
+
"""
|
|
317
|
+
|
|
318
|
+
psk_skip_session_ticket: NotRequired[bool]
|
|
319
|
+
"""
|
|
320
|
+
Whether to skip session tickets when using PSK.
|
|
321
|
+
"""
|
|
322
|
+
|
|
323
|
+
key_shares_limit: NotRequired[int]
|
|
324
|
+
"""
|
|
325
|
+
Maximum number of key shares to include in ClientHello.
|
|
326
|
+
"""
|
|
327
|
+
|
|
328
|
+
psk_dhe_ke: NotRequired[bool]
|
|
329
|
+
"""
|
|
330
|
+
Enables PSK with (EC)DHE key establishment (`psk_dhe_ke`).
|
|
331
|
+
"""
|
|
332
|
+
|
|
333
|
+
renegotiation: NotRequired[bool]
|
|
334
|
+
"""
|
|
335
|
+
Enables TLS renegotiation by sending the `renegotiation_info` extension.
|
|
336
|
+
"""
|
|
337
|
+
|
|
338
|
+
delegated_credentials: NotRequired[str]
|
|
339
|
+
"""
|
|
340
|
+
Delegated Credentials (RFC 9345).
|
|
341
|
+
|
|
342
|
+
Allows TLS 1.3 endpoints to use temporary delegated credentials
|
|
343
|
+
for authentication with reduced long-term key exposure.
|
|
344
|
+
"""
|
|
345
|
+
|
|
346
|
+
curves_list: NotRequired[str]
|
|
347
|
+
"""
|
|
348
|
+
List of supported elliptic curves.
|
|
349
|
+
"""
|
|
350
|
+
|
|
351
|
+
cipher_list: NotRequired[str]
|
|
352
|
+
"""
|
|
353
|
+
Cipher suite configuration string.
|
|
354
|
+
|
|
355
|
+
Uses BoringSSL's mini-language to select, enable, and prioritize ciphers.
|
|
356
|
+
"""
|
|
357
|
+
|
|
358
|
+
sigalgs_list: NotRequired[str]
|
|
359
|
+
"""
|
|
360
|
+
List of supported signature algorithms.
|
|
361
|
+
"""
|
|
362
|
+
|
|
363
|
+
certificate_compression_algorithms: NotRequired[
|
|
364
|
+
List[CertificateCompressionAlgorithm]
|
|
365
|
+
]
|
|
366
|
+
"""
|
|
367
|
+
Supported certificate compression algorithms (RFC 8879).
|
|
368
|
+
"""
|
|
369
|
+
|
|
370
|
+
extension_permutation: NotRequired[List[ExtensionType]]
|
|
371
|
+
"""
|
|
372
|
+
Supported TLS extensions, used for extension ordering/permutation.
|
|
373
|
+
"""
|
|
374
|
+
|
|
375
|
+
aes_hw_override: NotRequired[bool]
|
|
376
|
+
"""
|
|
377
|
+
Overrides AES hardware acceleration.
|
|
378
|
+
"""
|
|
379
|
+
|
|
380
|
+
preserve_tls13_cipher_list: NotRequired[bool]
|
|
381
|
+
"""
|
|
382
|
+
Sets whether to preserve the TLS 1.3 cipher list as configured by cipher_list.
|
|
383
|
+
|
|
384
|
+
By default, BoringSSL does not preserve the TLS 1.3 cipher list. When this option is disabled
|
|
385
|
+
(the default), BoringSSL uses its internal default TLS 1.3 cipher suites in its default order,
|
|
386
|
+
regardless of what is set via cipher_list.
|
|
387
|
+
|
|
388
|
+
When enabled, this option ensures that the TLS 1.3 cipher suites explicitly set via
|
|
389
|
+
cipher_list are retained in their original order, without being reordered or
|
|
390
|
+
modified by BoringSSL's internal logic. This is useful for maintaining specific cipher suite
|
|
391
|
+
priorities for TLS 1.3. Note that if cipher_list does not include any TLS 1.3
|
|
392
|
+
cipher suites, BoringSSL will still fall back to its default TLS 1.3 cipher suites and order.
|
|
393
|
+
"""
|
|
394
|
+
|
|
395
|
+
random_aes_hw_override: NotRequired[bool]
|
|
396
|
+
"""
|
|
397
|
+
Overrides the random AES hardware acceleration.
|
|
398
|
+
"""
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
class TlsOptions:
|
|
402
|
+
"""
|
|
403
|
+
TLS connection configuration options.
|
|
404
|
+
|
|
405
|
+
This struct provides fine-grained control over the behavior of TLS
|
|
406
|
+
connections, including:
|
|
407
|
+
- **Protocol negotiation** (ALPN, ALPS, TLS versions)
|
|
408
|
+
- **Session management** (tickets, PSK, key shares)
|
|
409
|
+
- **Security & privacy** (OCSP, GREASE, ECH, delegated credentials)
|
|
410
|
+
- **Performance tuning** (record size, cipher preferences, hardware overrides)
|
|
411
|
+
|
|
412
|
+
All fields are optional or have defaults. See each field for details.
|
|
413
|
+
"""
|
|
414
|
+
|
|
415
|
+
def __init__(self, **kwargs: Unpack[Params]) -> None:
|
|
416
|
+
"""
|
|
417
|
+
Creates a new TlsOptions.
|
|
418
|
+
"""
|
|
419
|
+
...
|