Skip to content

lkrequest-go v0.2.1

Choose a tag to compare

@ezxlabs-admin ezxlabs-admin released this 04 Sep 05:15
· 5 commits to main since this release

πŸš€ Features

  • macOS / Apple Silicon Support β€” darwin/arm64 now ships with an embedded library, so go get builds and runs on Apple Silicon without any manual setup. Earlier releases carried the darwin/arm64 embed declaration without the matching library, which made the package fail to compile on macOS with pattern lib/darwin_arm64/liblkrequest_ffi.dylib: no matching files found. The bundled macOS engine is built with synthetic-fp and quic-h3, like the Linux and Windows libraries, so fingerprint randomization and HTTP/3 are available there too.
  • Chrome 152 Preset β€” SetPreset("chrome_152") / NewClient("chrome_152"), captured from Chrome 152.0.7977.65 (Windows, August 2026). TCP TLS prepends an independently randomized GREASE code point to signature_algorithms ahead of the ML-DSA entries, and adds Chromium/BoringSSL's trust-anchor identifiers extension (0xca34) with its order reshuffled per ClientHello. HTTP/2 keeps Chrome 151's SETTINGS, connection window, pseudo-header order and priority shape. QUIC keeps the Chrome 151 signature and transport baseline minus the google_initial_rtt transport parameter (0x3127), which Chrome no longer sends; H3 SETTINGS retain the latest verified Chrome baseline because the capture did not establish a complete H3 exchange.
  • Chrome-Accurate HTTP/2 DATA Framing β€” Chrome presets now cap each outbound DATA payload at 16375 bytes, so the 9-byte frame header plus payload land in a single 16 KiB socket write the way Chromium does. Request bodies larger than that are split across more DATA frames than before; this is a fingerprint-fidelity improvement and needs no code change.

🐞 Fixes

  • Multipart Boundary No Longer Names the Library β€” the boundary was built as ----lkrequest{hex}, putting the crate name in the Content-Type of every upload, where a single server-side regex identified it whatever the TLS and HTTP/2 fingerprints said. It now matches what a real Chrome emits: ----WebKitFormBoundary followed by exactly 16 alphanumerics, drawn by rejection sampling so the character distribution is uniform. This changes the bytes on the wire β€” tests that pin the boundary or the exact request body need updating.
  • Multipart Field Names and Filenames Are Escaped β€” Multipart.AddText / AddFile interpolated caller-supplied names into Content-Disposition verbatim, so a name containing CR or LF could terminate the header line and append part headers, start an extra part, or forge the boundary. " now becomes %22, CR and LF become %0D and %0A, and a CR or LF in a part's content type is rejected outright since that header has no quoted form to escape into.
  • Sessions Are No Longer Capped at 64 Connections by Default β€” the implicit ceiling made unrelated high-concurrency workloads fail with session connection limit reached. The default is now unbounded; ClientBuilder.SetMaxConnectionsPerSession and SessionBuilder.SetMaxConnections still impose a hard budget when set. This revises the strict-enforcement note from 0.2.0: enforcement is unchanged, only the default ceiling is gone.
  • 304 Not Modified Is No Longer Treated as a Redirect β€” every 3xx was classified as a redirect, so a conditional request answered with 304 (and likewise 300 / 305 / 306) reached the Location lookup and failed with redirect response missing Location header. Only 301 / 302 / 303 / 307 / 308 are followed now; the rest are returned to the caller as-is.
  • Redirects Rewrite the Method Only Where the Spec Says To β€” 301, 302 and 303 unconditionally became GET, so a HEAD request came back as a GET, which Chrome does not do. 303 still rewrites everything except HEAD.
  • Multi-Layer Content-Encoding Is Decoded β€” only the outermost coding was handled, so gzip, br was returned still compressed under a header claiming otherwise. Codings are applied in reverse order now, on both Send() and SendStreaming().
  • Content-Encoding: deflate Accepts the zlib Form β€” only a bare raw-deflate stream was decodable, so servers sending the zlib-wrapped form the spec actually defines failed outright. Both the buffered and streaming paths sniff the header and pick the matching decoder.
  • Status-Code Retries Are Gated on Replay Safety β€” the error-retry path checked replay safety, the status path checked nothing, so a POST answered with 502 was sent twice. A non-idempotent method is now replayed only on a status that says it was not applied (429, 503); 502, 504 and the Cloudflare 520–530 range are ambiguous about whether the origin already processed the request and are returned to the caller instead. Safe methods are unaffected.
  • HTTP/2 Graceful Shutdown β€” a GOAWAY carrying NO_ERROR (which Google and Cloudflare send routinely for connection turnover) set no connection error, while the draining check keyed off "has error", so the driver kept opening streams the peer had already promised to refuse. Draining is keyed off GOAWAY receipt itself now, and queued requests fail over to a fresh connection.
  • HTTP/2 Responses Are Validated Rather Than Quietly Repaired β€” a content-length disagreeing with the DATA actually delivered was accepted (a response-length desync), unparseable headers were dropped, and a missing or malformed :status became 500. Connection-specific fields are now rejected, pseudo-header rules enforced, DATA held to the same standard as HEADERS, and a malformed response resets the stream instead of leaving the peer sending DATA on a stream already torn down.
  • HTTP/2 Connection State Machine β€” frames could be interleaved into a CONTINUATION sequence, HEADERS-path stream-state checks were weaker than the DATA path's, and an INITIAL_WINDOW_SIZE overflow mapped to the wrong error code. Fixing the DATA path also closed a connection-window leak where a frame on a stream that could not receive consumed window that was never replenished.
  • TLS Post-Handshake Message Reassembly β€” each record was treated as exactly one message, so a KeyUpdate sharing a record with a NewSessionTicket was silently dropped: read keys were never rotated and every subsequent record failed to decrypt. Coalesced tickets past the first were lost the same way. Decrypted bytes are buffered and only complete messages dispatched now.
  • The Handshake Fails on Server Choices the Client Never Offered β€” a TLS 1.2 named_curve, a ServerKeyExchange signature algorithm, or a TLS 1.3 CertificateVerify scheme was checked only against what the implementation supports, never against what the ClientHello advertised. Duplicate-extension detection also ran only on the HelloRetryRequest branch, and unsolicited TLS 1.2 extensions had no "did we offer this?" check at all.
  • TLS Record Layer Hardened and Session-Ticket Trust Bounded β€” plaintext handshake and alert records were still accepted after handshake keys were installed, an unknown record content type was silently skipped, TLS 1.2 resumption neither recorded nor checked Extended Master Secret state, and ticket lifetimes were unbounded (now capped at seven days).
  • The Peer's record_size_limit Is Honoured When Sending β€” the extension was advertised but never applied, so a peer that asked for smaller records got 16384-byte ones anyway.
  • A TLS 1.2 HelloRequest Is Refused With a Fatal Alert β€” it was dropped silently, which no browser does, leaving a behavioural probe for any server willing to send one. It now sends a fatal no_renegotiation and aborts, matching BoringSSL. Behaviour change: such a connection now ends in an error where it previously carried on.
  • A Connection Ending Without close_notify Is Distinguishable β€” the read loop now stops at close_notify rather than polling on, because anything arriving after it did not come from the peer, and those bytes were being appended to the response body.
  • ECH Rejection Aborts Instead of Returning an Unprotected Connection β€” when a server did not accept Encrypted ClientHello, the library logged it and carried on, handing back a connection whose true server name had never been protected, so the request ECH existed to hide went out in the clear. Both the TCP and QUIC paths now abort before any traffic keys exist, and the session redials once with the retry_configs the server supplied, as a browser does. Retrying without ECH is deliberately not a fallback. GREASE ECH is unaffected.
  • Alternative Services No Longer Supply the TLS Identity β€” an Alt-Svc entry or HTTPS RR names where to send packets, but the endpoint must still prove it may serve the origin. The advertised host was used as the SNI and certificate name, so the alternative authenticated as itself, and conforming deployments failed outright because an HTTPS RR target is typically a CDN's internal name serving the origin's certificate. The dial target still follows the advertisement.
  • Alternative-Service Parsing β€” the bracketed IPv6 authority form was stripped at parse time while URL host lookups keep it, so a bare 2001:db8::1 reached the dialer unusable; persist=1 is now parsed; h3=":0" no longer produces an alt-authority on a reserved port; and draft advertisements such as h3-29 are ignored, matching Chrome 140+.
  • DNS HTTPS/SVCB Records Are Read as Records β€” fields from same-priority records were merged together, producing endpoint descriptions no server ever published. AliasMode is followed now (with loop detection and a hop cap), and mandatory and no-default-alpn are honoured instead of silently dropped, so a client no longer connects with a protocol the endpoint declared it does not speak.
  • HTTPS-RR Discovery Issues One Query per Request Instead of Two β€” protocol discovery and the handshake's automatic ECH configuration each ran their own lookup. Beyond the extra round trip, the two answers could disagree, leaving the ECH config out of step with the endpoint the HTTP/3 decision was made against.
  • Cookie Name Prefixes Are Enforced β€” __Secure- and __Host- carry security meaning only if their requirements are checked, and a Secure cookie received over plain HTTP was stored regardless of its name.
  • HSTS Is Learned Only From a Secure Transport β€” a plaintext response could inject a Strict-Transport-Security policy into a session, and IP-literal hosts are never pinned now.
  • SOCKS5 and CONNECT Proxy Compatibility β€” the username/password sub-negotiation reply's version byte was never validated, and only an exact 200 completed a CONNECT tunnel where every 2xx is a success.
  • QUIC and HTTP/3 Validation β€” a QUIC ticket's max_early_data_size was accepted whenever non-zero rather than at the one value the spec allows, custom H3 profiles could emit reserved settings identifiers, and the H3 path was missing two of the three ECH configuration fallbacks the TCP path already had.