Repository navigation
Contributor wave 14: VMess link TLS fields, provider app-message hook, traffic-triggered re-probes (#346, #347, #349, #308) - #350
Merged
Conversation
Outbound health only changed through the observatory's periodic probes, and its interval sleep could not be woken. With leastPing and a long probeInterval, a server that died stayed selected until the next round: up to ten minutes with probeInterval 10m, every new flow failing. Flows now report failed opens. SOCKS/HTTP CONNECT, HTTP forwarding and TUN TCP (DNS TCP proxy included), and TUN UDP report the leaf they were routed to when its open times out or fails with a refused, reset or timed-out connection or a TLS, REALITY or transport handshake error. Remote closes, target refusals, DNS errors and a down local network are not reported. A report is a per-leaf atomic flag in the selection overlay plus one Notify wake-up, and only on the error path. The observatory watches its observed leaves and each observed balancer's fallback (fallbackTag or the default outbound). Its interval wait is now woken by reports: a reported leaf is probed again once 10 s have passed since its last probe, and when no observed member of a balancer is healthy, a failure through a member or the fallback has all members probed again, at most once per 15 s. Probe results go through the existing record path, so a failed re-probe moves leastPing to the next healthy member and a success keeps or restores the leaf. The scheduled round is unchanged and re-probes reuse its concurrency bound; without reports behaviour is as before. State is bounded by the leaf and balancer counts; no task or queue grows with the number of failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013187aoMHvrWEfXT9ArqxdU
A failed open could mark a healthy server unhealthy during a short local outage: re-probes run exactly when traffic fails, one failed probe set a leaf unhealthy, and nothing probed it again before the scheduled round. - A failed traffic-triggered re-probe of an outbound that is not unhealthy is no longer recorded. The outbound is probed again 10 s after that probe finished, and only that result counts. An outbound re-probes marked unhealthy is probed again 10 s later, then at doubling intervals up to probeInterval. Scheduled-round results are recorded as before and end any follow-up. - Cooldowns count from when a probe or a balancer pass finished, not when it started. A balancer's cooldown doubles after each pass in which every member's probe failed, capped at probeInterval, and resets when a member answers. - Reports are classified from typed io kinds only: refused, reset or timed out, EOF or InvalidData inside a TLS handshake, and REALITY RealCertificate. ConnectionAborted and HostUnreachable count as local network errors. Message-only errors (XHTTP, gRPC, XDRIVE, WebSocket, HTTP upgrade, HTTP/2 CONNECT, chained hop), Hysteria Connect and MASQUE Dial are no longer reported; their timeouts still are. - Leaves without a server of their own (freedom, blackhole, DNS, loopback) are not watched, observed or as a fallback. - Open timeouts stay reported, since a server that drops packets gives nothing else; the docs no longer claim a down local network is never reported. Tests drive a running core: SOCKS CONNECT, HTTP CONNECT, HTTP forwarding, TUN TCP, TUN UDP and TUN VLESS UDP report a refused open; SOCKS, HTTP forwarding, TUN TCP and TUN UDP report an open timeout; a SOCKS target refusal is not reported. The end-to-end test goes from a SOCKS flow through a leastPing balancer to failover on the other server. Unit tests cover the confirmation, the follow-ups, the cooldowns and the group back-off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013187aoMHvrWEfXT9ArqxdU
…ad window A re-probe still sets the health state, the last delay and the failure count, so leastPing and the quick move away from a dead server are unchanged, but only the scheduled round adds samples to the 16-sample window leastLoad reads for tolerance, average and deviation.
Panels such as V2Board write `fp` on every base64 JSON vmess:// link, also when `tls` is empty. v2rayN builds TLS settings only when `tls` names a security, so there the field configures nothing. Here the importer kept it and stream_settings refused the leftover parameter, so a plain WebSocket link failed with "profile contains an unsupported setting". With `tls` absent, empty or `none`, the JSON dialect now drops `sni`, `alpn` and `fp` before the stream mapping. A link with TLS maps them into tlsSettings as before; the URI dialect and the REALITY fields are unchanged.
The Swift and Kotlin doc comments of probeOutboundURL/probeOutboundUrl say "the running core", but not what a host gets on a core it loaded and has not started yet: Swift throws XrayCoreError.notRunning before reaching the C call, Kotlin XrayCoreException with RUNTIME_ERROR from it. docs/ffi.md and the C header already document the RUNTIME_ERROR, and ffi_outbound_probe_validates_outputs_handle_and_lifecycle tests it. Name the error in both comments and point to preflightStartupProbe, which runs the configured startup probe before start. No code change.
XrayPacketTunnelProvider keeps its runtime private and answers only the stats and close-connections requests, so a host app could not ask its tunnel for the connection, accounting, selection or health snapshot, pin a selector group or replace the routing policy without forking the provider. Add an open handleCustomAppMessage(_:core:) hook. handleAppMessage calls it with the active core for every message after the close-connections request and before the stats request; a non-nil result is sent back, nil falls through to the built-in handling. The default returns nil, so existing hosts see no change.
profile import: ignore TLS fields of a VMess JSON link without TLS
docs: say that an outbound probe needs a started core
apple: let a provider subclass answer its own app messages CHANGELOG.md: both Unreleased entries kept, this one after #346's.
Re-probe observed outbounds when real traffic fails to dial them Merged at 1a0eedb: the pull request's head 7b68352 and, on top of it, dec0iiyy's commit that keeps traffic-triggered re-probes out of the leastLoad window, the last open point of the review. CHANGELOG.md: the entry goes to the end of the Unreleased list.
handleAppMessage dropped a message that is not valid UTF-8 before the hook #349 added could see it, while the hook's documentation promises every message the provider does not handle itself. A host whose app and extension speak a binary format, a property list or protobuf, would have had its messages answered with nil. The provider now decodes the text only to recognise its own requests, which are text: a message that is not names none of them, goes to the hook, and without an answer from it gets nil as before. Hosts that do not override the hook see no change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge commits of the unchanged heads of #346, #347 and #349, and of #308 with one commit on top of its head, on current main (06ad5e2), so that the original PRs close as merged. One fix on top of #349.
vmess://link without TLS imports when it carriessni,alpnorfp; the fields are ignored instead of failing the importXrayPacketTunnelProviderhas an openhandleCustomAppMessage(_:core:)hook for a subclass's own app messagesprobeInterval#308 and the commit on top of it
The review of #308 left one point open: re-probe results went into the 16-sample window
leastLoadreads fortolerance, the average and the deviation, so one outage wrote several failures where the scheduled round would have written one, and they outlived the outage. The author has not answered since 2026-11-17.dec0iiyy wrote that change as one commit on top of the pull request's head and offered it to the author's branch. It is merged here at 1a0eedb, whose parent is #308's head 7b68352, so the pull request's own two commits are in unchanged and it closes as merged.
What the commit does: a re-probe still sets the health state, the last delay and the failure count, so
leastPingand the quick move away from a dead server are as #308 made them; only a probe of the scheduled round adds a sample to the window.reprobes_leave_the_least_load_window_to_the_scheduled_roundruns three scheduled probes, then a failed re-probe, the confirming probe, a recheck and a successful recheck against a SOCKS server that is switched off and on, and holds the window at(3, 1)throughout while the state goes unhealthy and back.docs/config-compatibility.mdand theCHANGELOG.mdentry say that the window counts scheduled probes only.Conflicts
CHANGELOG.mdonly; its entry and profile import: ignore TLS fields of a VMess JSON link without TLS #346's are both kept.CHANGELOG.mdonly. Its base is the 0.10.1 release, and its entry goes to the end of the current Unreleased list.tun.rsand the two documents merged without a conflict.Fix on top of #349 (e98a08a)
apple: hand app messages that are not text to handleCustomAppMessagehandleAppMessagedropped a message that is not valid UTF-8 before the new hook could see it, while the hook's documentation promises every message the provider does not handle itself. A host whose app and extension speak a binary format, a property list or protobuf, would have had its messages answered withnil.The provider now decodes the text only to recognise its own requests, which are text. A message that is not text names none of them, goes to the hook, and without an answer from it gets
nilas before. A host that does not override the hook sees no change. The doc comment andplatform/apple/README.mdsay that the message need not be text.Review notes
#346:
tlsabsent, empty ornone, the JSON dialect removessni,alpnandfpbefore the stream mapping. The REALITY fields are not removed, so a plain link that carriespbkstill fails. A link with TLS and the URI dialect are untouched.tlsnames a security. That was not checked against v2rayN's source here.#347:
XrayCoreError.notRunningfromwithDataPathHandlebefore the C call, the C API documentsRUNTIME_ERRORfor a loaded core that is not running, andpreflightStartupProbeexists in both wrappers.#349:
XrayCore, whosestartandstopare public. Nothing but the doc comment keeps a host from calling them. A subclass that keeps the core past the call still goes through the wrapper's call gate on every call, which checks the handle and throws once it is gone.#308:
burstObservatory) is to be rebased on top of this.Security check of the five commits that are new to this repository (#346, #347, #349, the two of #308, and the one on top): gitleaks with the repository's configuration finds nothing in them; none touches a workflow, a script, a manifest, a build script or
Cargo.lock; none addsunsafeor a binary file. The fix on top touches one Swift file and one README.Verification
vmess_import_tests,profile_import_testsandtooling_testspass, and the new test fails with main'svmess.rs.--locked:cargo fmt --all -- --check; clippy for the whole workspace with the CI flags;cargo test -p xray-config(739 passed, 0 failed, 1 ignored);cargo test -p xray-core-rs --lib(822 passed, 0 failed, 4 ignored), which holds Re-probe observed outbounds when real traffic fails to dial them #308's re-probe and call-site tests and the new window test;cargo doc --workspace --no-depswith-D warnings. All pass.swiftc -parseaccepts the changed file, and a small model of the handler's dispatch, compiled and run, answers text and non-text messages as intended. Theapplejob builds the package and runs its tests.🤖 Generated with Claude Code