The direct outbound opens one ICMP socket for each echo flow. The
sockets were kept for one minute after the last packet and their
number was not limited, so scanning hosts through the outbound could
accumulate an unbounded number of sockets, which has been reported to
panic the kernel on macOS.
Close idle flows after ICMPTimeout as the stacks do, and keep at most
1024 flows, closing a least recently active one when the limit is
reached.
When authentication failed, the reality client returned the error and
sent the fallback request from a goroutine on the same connection. The
TLS dialer closes the connection when the handshake returns an error, so
the request always failed with "use of closed network connection" and
the client closed the connection right after the target's handshake.
Send the request within the handshake context before returning the
error, so the caller owns the connection again once it gets the error.
The reality session id carried time.Now() instead of the configured
time, which is the NTP clock when ntp is enabled, so a client whose
system clock was off failed every handshake against a server that sets
max_time_difference. The certificate check after a failed
authentication also used the system clock and system roots instead of
the configured clock and certificate store, so it rejected a valid
target and skipped the fallback request.
Xray-core v26.7.11 to v26.9.7 refused REALITY clients older than
26.3.27 unless the server set minClientVer, and operators set it to
1.8.2, the version mihomo sends, to let third-party clients connect.
The setting stays after Xray-core dropped that default, and it rejects
sing-box, which sends 1.8.1. The version is only checked against the
server's minClientVer and maxClientVer, and Xray-core never released a
1.8.2, so send the same version as mihomo.
The random fingerprint picked one of chrome, firefox, edge, safari and
ios per process. Edge 85 and iOS 14 are no longer current browsers and
send no X25519MLKEM768 key share, so a process that picked one of them
failed every REALITY handshake against Xray-core v26.9.8 and later
servers. Pick only from fingerprints of current browsers.
BuildHandshakeState already copied the fingerprint's ALPN into the
config, so the loop assigned the extension its own protocols. The
reality ClientHello keeps carrying the fingerprint's ALPN, as in
Xray-core.
Xray-core v26.9.8 and later REALITY servers reject a ClientHello that
has no X25519MLKEM768 key share ahead of X25519 and fall back to the
target, so sing-box reality clients failed against them with "reality
verification failed". Removing the group and share also made the chrome
hello differ from the browser it imitates. Send the fingerprint's key
shares unchanged, as Xray-core does.
The randomized fingerprint picked the X25519MLKEM768 group and key share
with separate coin flips. A group without a share makes post-quantum
preferring servers send a HelloRetryRequest, which uTLS cannot answer
for X25519MLKEM768 and REALITY cannot relay; a share without the group
is rejected by OpenSSL with illegal_parameter. Always offer both.
The client hashed only the bytes its TLS stack consumed, so session
tickets sent together with the server Finished were left out and the
server did not authenticate the connection.