D.Msg.PackBuffer sizes its scratch space by the uncompressed message length
and silently allocates a new slice when that exceeds the given buffer, even
though the compressed result would fit. The udp hijack path in
listener/sing_tun/dns.go always sends the original buffer, producing a
correct-length datagram full of zeros or stale bytes whenever a reply's
uncompressed size exceeds SafeDnsPacketSize (e.g. 100+ A records for one
name). Copy the packed result back into the caller's buffer when it fits.
The tcp path in RelayDnsConn already guards against this; the udp path did
not.
Regenerate the random seed when FakeRandom ends in a TLS downgrade canary or the HelloRetryRequest suffix, as required by JLS v3. Use the configured random source for both client and server hellos.
Decide whether fallback is safe based on bytes actually written instead of JLS authentication status. This allows authenticated preflight failures, including HRR and TLS configuration mismatches, to relay the untouched ClientHello to the camouflage target.
Keep rejecting fallback after a partial or complete server flight, update jls-tls for pre-write alert suppression, and add coverage for both sides of the write boundary.
JLS v3 does not permit HelloRetryRequest during JLS authentication. Keep the ClientHello random unchanged across HRR and make clients continue as ordinary TLS with certificate verification.
When an authenticated ClientHello would require HRR, fail before writing handshake data and wrap ErrJLSAuthFailed. This allows stream and QUIC callers to forward the untouched handshake to the camouflage fallback instead of accepting a non-standard JLS exchange.
JLS authenticates the serialized ServerHello with only the random field zeroed. The previous marshalForJLS implementation reordered extensions to match rustls-jls's internal struct order, even when that order differed from the bytes sent on the wire.
That canonical order is not defined by TLS or the JLS specification and couples this package to a rustls-jls implementation detail. Use the normal marshal output when sending and the original wire bytes when receiving, preserving extension order and leaving the TLS transcript untouched.
This intentionally removes compatibility with rustls-jls clients that re-encode ServerHello extensions before JLS verification.