Skip to content

lkrequest-py v0.2.0

Choose a tag to compare

@ezxlabs-admin ezxlabs-admin released this 18 Aug 02:50
· 7 commits to main since this release

πŸš€ Features

  • System DNS Positive Cache β€” Added system_dns_cache_ttl and system_dns_cache_max_entries to Client and BlockingClient. The OS resolver already coalesces concurrent identical lookups process-wide; these cache successful, non-empty results for ttl seconds (default capacity 1024 entries). A 0 TTL keeps the coalescing while disabling the cache. It selects the system resolver, so it cannot be combined with dns; errors and empty results are never cached.
  • Shutdown Draining β€” Added drain_pending(timeout=None), its blocking counterpart blocking_drain_pending(...), and pending_requests(). Waiting for in-flight work before tearing down an event loop means results are still delivered rather than dropped on arrival. Counts are process-wide and cover every async call, not only requests.
  • HTTP/2 Pending-Request Bound β€” Added max_pending_h2_requests to Client and BlockingClient. HTTP/2 requests that exceed the peer's concurrent-stream limit now wait for a stream slot instead of failing, and this option caps how many may queue. Omit it (the default) for an unbounded queue; 0 is rejected with ValueError.
  • Synthetic Fingerprint Negotiability (synthetic-fp) β€” Added NegotiabilityFloor.UNIVERSAL, NegotiabilityFloor.PRESET_FAMILY, NegotiabilityFloor.custom(...), and Randomize.negotiability(...) so synthesized ClientHello profiles retain a configurable signature-algorithm compatibility floor.
  • Multi-hop Proxy Chains β€” Added ProxyConfig.parse_chain(...) and .through(...), with chain metadata via hop_count() and identity(). Client sessions, proxy pools, and session pools now accept either proxy URLs or ProxyConfig objects.
  • Mixed Proxy Transports β€” HTTP/1.1 and HTTP/2 can traverse ordered combinations of HTTP CONNECT, SOCKS5, and SOCKS5H hops. QUIC/HTTP3 supports all-SOCKS5 chains when the optional quic-h3 feature is enabled.
  • QUIC-TLS Profile Presets β€” Added TlsProfile.chrome_146_quic(), TlsProfile.chrome_150_quic(), and TlsProfile.chrome_151_quic(), exposing the ClientHello Chrome sends inside QUIC (previously reachable only through the bundled Client.chrome_1xx() presets). Pass one to Client(quic_fingerprint=...) when building a client manually; HTTP/3 otherwise reuses the main TLS profile.
  • Chrome 151 Preset β€” Added Client.chrome_151(), BlockingClient.chrome_151(), TlsProfile.chrome_151(), H2Profile.chrome_151(), QuicProfile.chrome_151(), and the "chrome_151" TLS/H2/QUIC profile names. Captured from Chrome 151.0.7922.72: TCP TLS and HTTP/2 keep Chrome 150's stable fields, while the QUIC-TLS capture omits the three ML-DSA signature algorithms; QUIC transport parameters and HTTP/3 SETTINGS stay aligned with Chrome 150.
  • Chrome 150 QUIC/H3 (quic-h3) β€” Client.chrome_150() now uses dedicated Chrome 150 QUIC TLS and HTTP/3 profiles instead of reusing Chrome 146. The preset covers captured signature algorithms, QUIC transport parameters, QPACK limits, navigation PRIORITY_UPDATE, connection-ID lengths, and Initial datagram sizing. Added QuicProfile.chrome_150() and the "chrome_150" QUIC profile name.

🐞 Fixes

  • No More Crashes From Late-Completing Requests β€” A request that finished after its event loop had closed used to print a RuntimeError: Event loop is closed traceback from whichever worker thread it landed on. Enough of them at once turned into Fatal Python error: _enter_buffered_busy and killed the process with SIGABRT β€” uncatchable, and it took the whole batch down. Results arriving after the loop closes are now dropped silently, since nothing is left to receive them.
  • Multi-Address Connect Fallback β€” Connecting now tries every address a hostname resolves to, racing them Happy Eyeballs style (RFC 8305) with interleaved address families, rather than giving up when the first candidate is unreachable. Applies to direct TCP and to SOCKS5 proxies.
  • HTTP/2 Stream-Limit Backpressure β€” Requests beyond the peer's advertised MAX_CONCURRENT_STREAMS now wait asynchronously for a stream slot instead of failing with a local capacity error.
  • Redirects Over Reused HTTP/1.1 Connections β€” Following a redirect no longer fails when the pooled HTTP/1.1 connection was torn down in the meantime. The reuse attempt surfaces as hyper's operation was canceled, which is now recognised as a closed connection, so the request is retried on a fresh connection instead of erroring out. Affects any server that hangs up after answering a 3xx β€” a common pattern after POST.
  • HTTP/2 1xx Interim Responses β€” The HTTP/2 driver now consumes 1xx informational responses β€” such as the 103 Early Hints Cloudflare sends ahead of its 200 β€” and returns the final response that follows, instead of reporting the interim status as the final one. A plain GET https://www.cloudflare.com/ previously came back as 103.
  • Connection Limit Enforcement β€” max_connections now bounds physical connections, counting those still being dialled and those checked out by an in-flight request rather than only what sits idle in the pool. Exceeding the limit raises instead of quietly opening another connection, and an idle HTTP/1.1 connection is evicted first so one origin's idle connections cannot starve another. PoolStats.total correspondingly reports physical connections in use rather than pooled entries.
  • Optional Client Certificate Requests β€” A server that asks for a client certificate no longer breaks the handshake. TLS 1.2 and TLS 1.3 now answer a CertificateRequest with an empty client Certificate message β€” echoing the request context on TLS 1.3, as RFC 8446 Β§4.4.2 requires β€” so endpoints with optional mutual TLS complete the handshake instead of failing.
  • TLS Handshake Reassembly β€” TLS 1.2 and TLS 1.3 handshake messages fragmented across multiple records are now buffered and reassembled correctly, preventing failures such as truncated handshake message in record without changing ClientHello or fingerprint output.
  • SOCKS5 UDP Relay Compatibility β€” QUIC-over-SOCKS5 accepts relay replies from the advertised source IP even when the relay uses a different egress port, preventing affected HTTP/3 requests from hanging.
  • Package Version Reporting β€” lkrequest.__version__ is now read from installed distribution metadata instead of being maintained as a separate hard-coded value.
  • TLS 1.3 ECH + HelloRetryRequest β€” Real ECH CH2 now reuses the ECH configuration, HPKE sender context, Inner random, GREASE values, extension permutation, and fake ECH bytes. HRR confirmation, selected groups, cookie-only retries, invalid extensions, dummy CCS, and local fatal alerts now follow the browser/RFC flow.
  • ECH + PSK + HRR Binders β€” pre_shared_key remains exclusively in ClientHelloInner; CH1 and CH2 binders now use the correct truncated Inner transcripts, including message_hash(ClientHelloInner1) + HRR for CH2.
  • QUIC/H3 HRR State Transitions β€” QUIC revokes 0-RTT stream and packet state after HRR and maps local TLS alerts to QUIC CRYPTO_ERROR codes.