feat: enable udpgw client via tun2proxy CLI API — no fork needed#271
Merged
therealaleph merged 1 commit intotherealaleph:mainfrom Apr 26, 2026
Merged
Conversation
Uses tun2proxy_run_with_cli_args (the C API) via dlsym instead of modifying the JNI run() signature. The upstream tun2proxy maintainer recommended this path — the CLI API accepts --udpgw-server natively. - Cargo.toml: enable udpgw feature, remove [patch.crates-io] - MhrvVpnService.kt: build CLI args with --udpgw-server in full mode - Native.kt + android_jni.rs: dlsym wrapper for the C API - Tun2proxy.kt: reverted to upstream signature No fork, no patch, no submodule. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Whish there was an easy way to use this on the other platforms as well. do you think proxifier would be able to use the somehow? |
Contributor
Author
|
@Feiabyte |
does that mean if i use proxifier i can get the same results as on android? |
therealaleph
added a commit
that referenced
this pull request
Apr 26, 2026
Move from yyoyoian-pixel/tun2proxy fork (with patched JNI signature) to canonical tun2proxy 0.7.21 from crates.io with feature flag "udpgw". Cargo.toml [patch.crates-io] section removed entirely. The Android side now resolves tun2proxy_run_with_cli_args at runtime via dlsym from libtun2proxy.so, which is the upstream maintainer's recommended path for callers that need full CLI flexibility. mhrv-rs builds the CLI string in MhrvVpnService and passes it through Native.runTun2proxy → src/android_jni.rs → dlsym → tun2proxy. Future tun2proxy upgrades are now a single Cargo version bump. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Enables udpgw on Android using upstream tun2proxy's
tun2proxy_run_with_cli_argsC API — no fork, no patch, no submodule.The tun2proxy maintainer recommended this approach over modifying the JNI
run()signature. The CLI API accepts--udpgw-servernatively and offers more flexibility.How it works
Cargo.toml: enableudpgwfeature on upstream tun2proxy (features = ["udpgw"]), remove[patch.crates-io]MhrvVpnService.kt: builds CLI args string with--udpgw-server 198.18.0.1:7300in full modeNative.runTun2proxy()→ Rust JNI wrapper resolvestun2proxy_run_with_cli_argsat runtime viadlsymfromlibtun2proxy.soTun2proxy.kt: reverted to upstream signature (no extra parameter)Why dlsym?
Android's linker namespaces prevent compile-time cross-
.sosymbol resolution.libmhrv_rs.socan't statically link againstlibtun2proxy.so— the app crashes on load withUnsatisfiedLinkError. Runtimedlsymavoids this cleanly.Changes
Cargo.tomlfeatures = ["udpgw"], remove[patch.crates-io]Cargo.lockMhrvVpnService.kt--udpgw-serverin full modeNative.ktrunTun2proxy(cliArgs, tunMtu)declarationandroid_jni.rsdlsymwrapper fortun2proxy_run_with_cli_argsTun2proxy.ktTest plan
Tun2proxy.stop()cleanly shuts down🤖 Generated with Claude Code