ssl2 2.0.0__tar.gz → 2.1.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ssl2
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: PEP 748 TLS interface: typed ClientHello model and parser, JA3, JA4 and Akamai fingerprints, proxies, sockets and asyncio streams
5
5
  Requires-Python: >=3.14
6
6
  Project-URL: Repository, https://github.com/baobien-dev/ssl2
@@ -150,7 +150,7 @@ proxy = Proxy.parse("socks5h://user:secret@proxy.example:1080") # http, https,
150
150
  print(proxy.scheme, proxy.host, proxy.port, proxy.credentials)
151
151
  ```
152
152
 
153
- `socks4` and `socks5` resolve the destination locally, `socks4a`, `socks5h` and the HTTP schemes let the proxy resolve it, and an `https` proxy carries TLS inside TLS with the same client context. A refusal raises `ProxyError` with the proxy's reason.
153
+ `socks4` and `socks5` resolve the destination locally, `socks4a`, `socks5h` and the HTTP schemes let the proxy resolve it, and an `https` proxy carries TLS inside TLS with the same client context, or with `proxy_context=` on `connect` when given; CONNECT is HTTP/1.1, so that context should offer only `http/1.1`. A refusal raises `ProxyError` with the proxy's reason.
154
154
 
155
155
  ## Sockets and streams on any engine
156
156
 
@@ -175,7 +175,7 @@ async def main() -> None:
175
175
  asyncio.run(main())
176
176
  ```
177
177
 
178
- `context` is an engine's `ClientContext`. A peer that drops TCP without close_notify reads as `b""`, the same default the `ssl` module has. On a direct connection, and behind an HTTP or SOCKS proxy, both hand the TCP socket to the engine through `TLSBuffer.attach`, so records move between the kernel and the TLS state without a stop in Python; behind an HTTPS proxy, or over any other `AsyncTransport`, the records go through the buffer's memory BIOs instead. A socket timeout applies to every wait.
178
+ `context` is an engine's `ClientContext`. `server_hostname=` names the server for SNI and certificate verification when the address is not that name, such as an IP address picked in advance. A peer that drops TCP without close_notify reads as `b""`, the same default the `ssl` module has. On a direct connection, and behind an HTTP or SOCKS proxy, both hand the TCP socket to the engine through `TLSBuffer.attach`, so records move between the kernel and the TLS state without a stop in Python; behind an HTTPS proxy, or over any other `AsyncTransport`, the records go through the buffer's memory BIOs instead. A socket timeout applies to every wait.
179
179
 
180
180
  ## Writing an engine
181
181
 
@@ -142,7 +142,7 @@ proxy = Proxy.parse("socks5h://user:secret@proxy.example:1080") # http, https,
142
142
  print(proxy.scheme, proxy.host, proxy.port, proxy.credentials)
143
143
  ```
144
144
 
145
- `socks4` and `socks5` resolve the destination locally, `socks4a`, `socks5h` and the HTTP schemes let the proxy resolve it, and an `https` proxy carries TLS inside TLS with the same client context. A refusal raises `ProxyError` with the proxy's reason.
145
+ `socks4` and `socks5` resolve the destination locally, `socks4a`, `socks5h` and the HTTP schemes let the proxy resolve it, and an `https` proxy carries TLS inside TLS with the same client context, or with `proxy_context=` on `connect` when given; CONNECT is HTTP/1.1, so that context should offer only `http/1.1`. A refusal raises `ProxyError` with the proxy's reason.
146
146
 
147
147
  ## Sockets and streams on any engine
148
148
 
@@ -167,7 +167,7 @@ async def main() -> None:
167
167
  asyncio.run(main())
168
168
  ```
169
169
 
170
- `context` is an engine's `ClientContext`. A peer that drops TCP without close_notify reads as `b""`, the same default the `ssl` module has. On a direct connection, and behind an HTTP or SOCKS proxy, both hand the TCP socket to the engine through `TLSBuffer.attach`, so records move between the kernel and the TLS state without a stop in Python; behind an HTTPS proxy, or over any other `AsyncTransport`, the records go through the buffer's memory BIOs instead. A socket timeout applies to every wait.
170
+ `context` is an engine's `ClientContext`. `server_hostname=` names the server for SNI and certificate verification when the address is not that name, such as an IP address picked in advance. A peer that drops TCP without close_notify reads as `b""`, the same default the `ssl` module has. On a direct connection, and behind an HTTP or SOCKS proxy, both hand the TCP socket to the engine through `TLSBuffer.attach`, so records move between the kernel and the TLS state without a stop in Python; behind an HTTPS proxy, or over any other `AsyncTransport`, the records go through the buffer's memory BIOs instead. A socket timeout applies to every wait.
171
171
 
172
172
  ## Writing an engine
173
173
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ssl2"
3
- version = "2.0.0"
3
+ version = "2.1.0"
4
4
  description = "PEP 748 TLS interface: typed ClientHello model and parser, JA3, JA4 and Akamai fingerprints, proxies, sockets and asyncio streams"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.14"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ssl2"
3
- version = "2.0.0"
3
+ version = "2.1.0"
4
4
  description = "PEP 748 TLS interface: typed ClientHello model and parser, JA3, JA4 and Akamai fingerprints, proxies, sockets and asyncio streams"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.14"
@@ -109,11 +109,17 @@ class TLSStream:
109
109
  *,
110
110
  proxy: Proxy | None = None,
111
111
  timeout: float | None = None,
112
+ proxy_context: ClientContext | None = None,
113
+ server_hostname: str | None = None,
112
114
  ) -> Self:
113
115
  async with asyncio.timeout(timeout):
114
- tunnel = await cls.tunnel(context, address, proxy)
116
+ tunnel = await cls.tunnel(
117
+ context if proxy_context is None else proxy_context, address, proxy
118
+ )
115
119
  try:
116
- buffer = context.create_buffer(address[0])
120
+ buffer = context.create_buffer(
121
+ address[0] if server_hostname is None else server_hostname
122
+ )
117
123
  if tunnel.socket is not None and not tunnel.leftover:
118
124
  return await cls.open_socket(context, buffer, tunnel.socket)
119
125
  return await cls.open(
@@ -196,14 +196,22 @@ class TLSSocket:
196
196
  *,
197
197
  proxy: Proxy | None = None,
198
198
  timeout: float | None = None,
199
+ proxy_context: ClientContext | None = None,
200
+ server_hostname: str | None = None,
199
201
  ) -> Self:
200
- buffer = context.create_buffer(address[0])
202
+ buffer = context.create_buffer(
203
+ address[0] if server_hostname is None else server_hostname
204
+ )
201
205
  if proxy is None:
202
206
  return cls.open_socket(
203
207
  context, buffer, socket.create_connection(address, timeout=timeout)
204
208
  )
205
209
  if proxy.scheme is ProxyScheme.HTTPS:
206
- hop = cls.connect(context, (proxy.host, proxy.port), timeout=timeout)
210
+ hop = cls.connect(
211
+ context if proxy_context is None else proxy_context,
212
+ (proxy.host, proxy.port),
213
+ timeout=timeout,
214
+ )
207
215
  try:
208
216
  return cls.open(context, buffer, hop, cls._tunnel(proxy, address, hop))
209
217
  except BaseException:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes