Repository navigation
Use native Xray TUN for connection info and updates - #6109
eliotcougar wants to merge 18 commits into
Conversation
|
关闭了本地端口的用户,只是实现测试连接还是不够的;因为更新订阅和下载geo 等功能也是要依赖这个本地端口。 |
In case of Assets and Subscriptions, should we let users choose "Update without proxy" vs "Update through proxy", like in v2rayN?.. |
09da5be to
0c2a141
Compare
|
Security follow-up pushed in a00589a. The daemon's dynamic receiver previously combined The fix separates the two trust boundaries:
Validation on an API 33 emulator confirmed that an external shell-UID stop message was not delivered and the tunnel remained connected, while the app's own UI stop message still worked. The focused unit test and Play Store debug build also pass. @2dust, a related but broader privacy issue is that existing code still writes some complete subscription/configuration/download/WebDAV URLs, and some URL-bearing exception messages, to Logcat. Android's guidance recommends removing sensitive values and keeping production log messages predictable: https://developer.android.com/privacy-and-security/risks/log-info-disclosure Would you be open to a separate, small PR that removes those URL values and retains only operation names and safe status codes? I kept that cleanup out of #6109 to avoid expanding this PR's scope and merge noise. |
83a2eff to
d6eb2c3
Compare
Use the active Xray core to fetch the configured connection-info URL when VPN mode runs with Xray TUN and the local proxy is disabled. This restores the country and IP result without requiring a local proxy inbound. Preserve the existing proxy-based path for configurations that expose or force the local proxy, including HEV and root modes. Pin AndroidLibXrayLite to the new GetUrlContent API.
Pass the app proxy tag to the core-backed URL fetch instead of leaving the request to normal routing. This prevents direct or alternate routing rules from changing the country and IP reported by the current-connection test. Advance AndroidLibXrayLite to the explicit outbound API so Xray TUN retains connection-info parity when the local proxy listener is disabled.
Resolve the primary balancer's first principle target when the running profile is a policy group, then fetch connection metadata through that concrete outbound. Keep the existing proxy-tag path unchanged for all other profiles.
Use the running core to download subscriptions and asset files when native Xray TUN is active without a local proxy. Stream responses through a shared cache file so binary geodata stays intact and large payloads never cross Binder, while preserving subscription headers and the existing proxy/direct paths for other modes.
Use per-attempt staging files so overlapping updates cannot corrupt one another. Reject empty, unsolicited partial-content, and length-mismatched responses, and advance AndroidLib to its atomic file-replacement implementation.
The service receiver shared its filter with system screen broadcasts and was exported on Android 13+, allowing external apps to send internal control messages, including URL download requests through the active core. Split screen-state handling into its own receiver and register the internal service action as not exported. Run downloads in a service-owned scope so shutdown cancels pending work and suppresses late ResultReceiver callbacks.
The upstream merge in 4bae3a4 retained both upstream's proxy-based IP lookup and this branch's core-aware lookup. A successful connection test therefore queried the endpoint twice and could publish two results. In native Xray TUN mode it also tried the local proxy even when that listener was disabled. Build one complete ConnectionTestResult after a single mode-appropriate lookup, then publish it once. Native TUN keeps using the active core and outbound; HEV, proxy-only and root modes retain their existing proxy path. Failed delay tests skip enrichment, and unavailable IP information does not discard a successful delay result. Reuse the existing service-owned URL-request scope and check cancellation before enrichment and delivery, so connection-test work does not publish a stale result after its core session ends. Keep the deterministic result assembly in SpeedtestManager, with regression tests for successful, zero, failed and unenriched results. Validation: all 63 Play Store unit tests, Kotlin compilation and four-ABI debug assembly passed. API 37.1 Pixel 9 Pro emulator checks passed in HEV mode and native Xray TUN mode with the local SOCKS proxy disabled. The HEV check recorded one IP-info endpoint connection per successful test.
Replace the obsolete SOCKS-only warning with wording explaining that subscription updates and similar actions use the active VPN tunnel when the local proxy is disabled. Update the summary in all nine supported locales without changing setting behavior. Validation: locale XML checks, git diff --check, and :app:assemblePlaystoreDebug passed.
Use the core download bridge for GitHub release metadata when native Xray TUN is active without a local proxy. Once the daemon accepts a request, keep failures on that path instead of bypassing the tunnel; preserve the existing direct and local-proxy behavior in other modes. Share one eligibility decision across connection info and app-owned downloads, excluding HEV, root, and root-LAN modes where a local proxy is forced. Advance AndroidLib for correct custom Host handling and cover the routing decisions with focused unit tests.
Restore the Utils import still required by native asset-download staging. Upstream removed its old built-in-row UUID use, but this branch must retain unique temporary download paths and validation before replacing an asset. Rebased onto upstream 2.3.8 with AndroidLibXrayLite b4a7cad. The matching four-ABI AAR, native Go and race tests, and app Play Store debug compilation, manifest processing and JVM tests pass.
d6eb2c3 to
252e262
Compare
Resolve shared-resource conflicts without dropping feature-specific semantics or current upstream translations. Retain upstream service and UI updates, and migrate feature regression tests to the upstream JUnit Platform setup. Validation: PlaystoreDebug JVM suite, Kotlin compilation and APK assembly passed. All declared ABIs contain the current Xray library and both HEV libraries. Full device and OEM lifecycle regression coverage was not run.
Stop resolving the custom library gitlink to an older upstream release tag. Build AndroidLibXrayLite at the checked-out source revision with the workflow NDK and its pinned Go mobile tools, including the assets and all four default Android ABIs. Keep HEV packaging and release signing unchanged so required native-TUN APIs are present in clean CI builds.
Resolve the subscription-update conflict by retaining upstream SubscriptionUsageInfo capture through the daemon/core download path. Forward final response headers alongside the completed body, then persist or clear account metadata only after a successful subscription import. Pin AndroidLibXrayLite to db309b146a17698bf1029989b19fd7007a0daa98, whose compatible DownloadUrlToFileWithHeaders API retains selected-outbound routing and transactional downloads. Eligible native-TUN subscription requests fail closed on core failure, daemon unavailability, or empty content; other modes retain their existing HTTP behavior. Preserve upstream pill-group UI, Kotlin/Gradle versions, and Azerbaijani locale, updating that locale for the local-proxy setting. Validation: 30 focused JVM tests and the full 133-test Play Store debug JVM suite passed without failures or skips; Kotlin compilation and x86_64 debug assembly passed using the freshly built four-ABI AAR. Packaged JNI bytes match that AAR and both HEV libraries match official v2.3.13 inputs. Instruction-file staging gates and whitespace checks passed. Android IPC, native-TUN live routing, and service runtime scenarios were not run because the parent owns the VM.
Resolve AndroidLibXrayLite to the URL-request feature branch merged with upstream v26.10.31. This keeps outbound-aware URL downloads and response headers while adopting the current Xray core. Retain upstream DNS handling, WireGuard fixes, and HEV 2.19.3.
Keep the early visual delay result and use the active outbound for IP lookup when required. Preserve asset replacement failure reporting across both download paths and pin the corresponding AndroidLibXrayLite merge.
Track the AndroidLibXrayLite revision that keeps URL request and observatory tests independently mergeable. Production native source is identical.
Use the native outbound resolver for IP lookup and downloads so they honor a configured fallback during observatory warm-up.
Summary
proxyoutboundHostauthorities, user agents, and embedded URL credentialsRoot cause
The connection test measures delay and then requests Current connection info test URL to display the exit country code and IP address. Subscription and asset updates similarly relied on an HTTP client configured for the local proxy. Native Xray TUN can run with that proxy disabled, leaving no listener for these requests even though the core and tunnel are active.
Application update checks had a related problem: the app first fetched GitHub release metadata directly. Because v2rayNG excludes its own process from its VPN interface, that request could bypass the active Xray connection. With the local proxy disabled, there was no app-owned path that followed the selected outbound.
An unqualified core request would not be equivalent: user routing rules could send the URL or its resolved IP through
director another detour, producing incorrect connection information or bypassing the selected route for updates.The daemon also registered its internal service action in the same dynamic receiver filter as system screen broadcasts. On Android 13 and newer, that mixed receiver was exported, allowing another app to send internal control messages. Once
MSG_DOWNLOAD_URLwas added, this included arbitrary URL, header, timeout, andResultReceiverinput, creating a request and success oracle through the user's active tunnel.Implementation
The app sends eligible requests to the daemon process, which downloads them through the running core and an explicit outbound. Ordinary profiles use
proxy; primary policy groups resolvebalancer-mainand use its first non-empty principle target.One shared eligibility decision now controls connection-info and app-owned download routing. It selects the core only for native Xray TUN with the local proxy disabled, and excludes HEV, root, and root-LAN configurations because those modes force a local proxy regardless of the visible setting.
The application update checker uses the same core download bridge for GitHub release metadata. Once the daemon accepts an eligible request, a transfer failure is reported instead of silently retrying outside the tunnel. The eventual APK link still opens in the user's browser, whose traffic is handled by the VPN normally.
Subscription headers, custom user agents, custom
Hostauthorities, and embedded URL credentials are preserved. Binary and large responses are streamed through a UUID-constrained cache file, avoiding string corruption and Binder payload limits.Asset updates use a separate UUID staging file for every attempt. This prevents overlapping updates from writing through the same temporary inode. A downloaded asset is promoted only when it is non-empty; direct HTTP downloads also reject unsolicited partial-content responses and declared-length mismatches. The AndroidLib method writes through a sibling temporary file and atomically replaces its destination only after the transfer completes, so network, write, or close failures preserve the previous file.
The internal service-action receiver is separate from the screen-state receiver and registered with
RECEIVER_NOT_EXPORTED. System screen broadcasts keep their existing receiver behavior. URL downloads run in a service-ownedSupervisorJobscope; stopping the core cancels the scope and prevents a cancelled request from delivering a lateResultReceivercallback. The conflict resolution retains upstream request IDs, cancellation callbacks, and the dedicated connection-test scope while keeping URL downloads independently owned by the core lifecycle.Fallback behavior remains deliberate:
For strategies that expose several principle candidates, policy-group selection is intentionally best-effort and does not advance random or round-robin state.
AndroidLib dependency
This branch updates the AndroidLibXrayLite gitlink to 2dust/AndroidLibXrayLite#205, which provides:
CoreController.GetUrlContent(url, outboundTag)CoreController.GetBalancerPrincipleTarget(balancerTag)CoreController.DownloadUrlToFile(url, outboundTag, headersJSON, filePath, timeoutMillis)CoreController.DownloadUrlToFileWithHeaders(...)to preserve response metadata such as subscription usage headersHostauthoritiesValidation
On app head
f6b84c9e7, merged with upstream57907cf35(2.3.15), using AndroidLib #205 at9057fa777and HEV 2.19.3:go test -race ./...andgo vet ./...after merging upstream2ffe5f794(v26.10.31).git diff --checkpassed. All three branches were updated with merge commits and ordinary fast-forward pushes.Not run: live native-Xray-TUN connection-info, subscription/asset/application-update downloads, sender-boundary and service lifecycle scenarios on the updated heads. No ADB device was attached; existing emulator processes had unresolved ownership and were left running. Compilation and JVM/Go tests do not establish device behavior.
The native repository's Actions runs are marked
action_requiredbefore any jobs start. Maintainer approval is needed for hosted CI; no failing CI test job was recorded.Fixes #5523