Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions android-app/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.gradle.api.tasks.Exec
import java.io.File
import java.io.FileInputStream
import java.util.Properties

Expand Down Expand Up @@ -118,9 +119,42 @@ dependencies {
val buildRust by tasks.registering(Exec::class) {
group = "build"
description = "Cross-compile plane-core (Rust) into jniLibs via cargo-ndk"
workingDir = rootProject.projectDir.parentFile // 仓库根目录(android-app 的上一级)
workingDir = File(rootProject.projectDir.parentFile, "plane-core")
val profile = if (project.hasProperty("rustRelease")) "release" else "debug"
commandLine("bash", "scripts/build-rust.sh", profile)

// 用 cargo 和 cargo-ndk 的全路径,绕过 MSYS2 bash 的 HOME/PATH 问题。
// cargo 执行时本身会正确处理 Rust 工具链。
val cargoHome = (System.getenv("CARGO_HOME")
?: "${System.getProperty("user.home")}\\.cargo").replace("\\", "/")
val cargoExe = "$cargoHome/bin/cargo"
// 将 cargo/bin 加入 PATH(bash 的 MSYS2 转换会破坏 /mnt/c/... 路径,
// 但直接传给子进程的 PATH 条目若为 C:/... 格式,MSYS2 在 exec 时也会转换。
// 因此改为直接用 cargo 跑 ndk 子命令,不再依赖 bash 脚本做路径发现。)
val abis = listOf("arm64-v8a", "armeabi-v7a", "x86_64")
val jniLibsDir = file("src/main/jniLibs")
val outDir = jniLibsDir.absolutePath.replace("\\", "/")
// 构建 cargo ndk 参数
val args = mutableListOf(cargoExe, "ndk")
for (abi in abis) { args.add("-t"); args.add(abi) }
args.add("-o"); args.add(outDir)
args.add("build")
if (profile == "release") { args.add("--release") }
commandLine(args)

// 传递 ANDROID_NDK_HOME
var ndkHome = System.getenv("ANDROID_NDK_HOME")
?: System.getenv("ANDROID_SDK_ROOT")
?: System.getenv("ANDROID_HOME")
if (ndkHome != null) {
val ndkDir = File(ndkHome, "ndk")
if (ndkDir.isDirectory) {
val versions = ndkDir.listFiles()?.filter { it.isDirectory }?.sortedByDescending { it.name }
if (!versions.isNullOrEmpty()) {
ndkHome = versions[0].absolutePath.replace("\\", "/")
}
}
environment("ANDROID_NDK_HOME", ndkHome)
}
}

tasks.named("preBuild") {
Expand Down
109 changes: 109 additions & 0 deletions desktop/src-tauri/resources/config-templates/proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
localPort: 1080
remoteServers:
- host: 54.234.196.30
port: 9090
cipher: chacha20
cipherKey: your-cipher-key
ssl: false
cluster: failover
loadBalance: roundrobin
timeoutMs: 8000
connectionsPerNode: 1
httpProxyEnabled: true
route:
defaultRoute: proxy
proxyList:
- "*.google.com"
- "*.google.com.hk"
- "*.googleapis.com"
- "*.gstatic.com"
- "*.googleusercontent.com"
- "*.googleadservices.com"
- "*.googlesyndication.com"
- "*.googletagmanager.com"
- "*.googletagservices.com"
- "*.google-analytics.com"
- "*.ggpht.com"
- "*.github.com"
- github.com
- "*.githubusercontent.com"
- "*.ghcr.io"
- "*.stackoverflow.com"
- "*.stackexchange.com"
- "*.wikipedia.org"
- "*.wikimedia.org"
- "*.youtube.com"
- "*.ytimg.com"
- "*.googlevideo.com"
- "*.twitter.com"
- twitter.com
- "*.x.com"
- x.com
- "*.twimg.com"
- "*.openai.com"
- "*.chatgpt.com"
- "*.anthropic.com"
- "*.claude.ai"
- "*.reddit.com"
- "*.medium.com"
- "*.docker.io"
- "*.docker.com"
- "*.npmjs.org"
- "*.npmjs.com"
- "*.cloudflare.com"
- "*.amazonaws.com"
directList:
- "*.meituan.com"
- "*.sankuai.com"
- "*.dianping.com"
- "*.neixin.cn"
- "*.baidu.com"
- "*.qq.com"
- "*.weixin.qq.com"
- "*.wechat.com"
- "*.aliyun.com"
- "*.aliyuncs.com"
- "*.taobao.com"
- "*.tmall.com"
- "*.jd.com"
- "*.bilibili.com"
- "*.bilivideo.com"
- "*.hdslb.com"
- "*.zhihu.com"
- "*.163.com"
- "*.126.com"
- "*.chaoxing.com"
- "*.vocabgo.com"
- "*.apple.com"
- "*.icloud.com"
- "*.cdn-apple.com"
- "*.aaplimg.com"
- "*.tencent.com"
- "*.myqcloud.com"
- "*.gtimg.cn"
- "*.idqqimg.com"
- "*.csdn.net"
- "*.douyin.com"
- "*.bytedance.com"
- "*.pstatp.com"
- "*.snssdk.com"
- "*.sina.com"
- "*.sina.com.cn"
- "*.sinaimg.cn"
- "*.weibo.com"
- "*.sogou.com"
- "*.sogo.com"
- "*.360.cn"
- "*.so.com"
- "*.cnblogs.com"
- "*.jianshu.com"
- "*.gitee.com"
- "*.coding.net"
- "*.dingtalk.com"
- "*.feishu.cn"
- "*.xuexitong.com"
- 127.0.0.1
- localhost
systemProxy:
enabled: false
host: 127.0.0.1
114 changes: 114 additions & 0 deletions desktop/src-tauri/resources/config-templates/tun.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# TUN Adapter 配置文件

[tun]
name = "utun9"
address = "198.18.0.1"
netmask = "255.254.0.0"
mtu = 1500
enabled = true

[fakeip]
range = "198.18.0.0/15"
capacity = 65536

[proxy]
socks5_addr = "127.0.0.1:1080"
health_check_interval = 5
health_failure_threshold = 3

[routing]
default_action = "proxy"

# --- 内网域名直连(最高优先级)---
[[routing.rules]]
type = "domain_suffix"
value = "sankuai.com"
action = "direct"

[[routing.rules]]
type = "domain_suffix"
value = "meituan.com"
action = "direct"

[[routing.rules]]
type = "domain_suffix"
value = "sankuai.info"
action = "direct"

[[routing.rules]]
type = "domain_suffix"
value = "neixin.cn"
action = "direct"

[[routing.rules]]
type = "domain_suffix"
value = "dianping.com"
action = "direct"

[[routing.rules]]
type = "domain_suffix"
value = "meituan.net"
action = "direct"

# --- 通用直连规则 ---
[[routing.rules]]
type = "domain_suffix"
value = "cn"
action = "direct"

[[routing.rules]]
type = "domain_suffix"
value = "local"
action = "direct"

[[routing.rules]]
type = "domain_keyword"
value = "baidu"
action = "direct"

[[routing.rules]]
type = "domain_keyword"
value = "aliyun"
action = "direct"

[[routing.rules]]
type = "ip_cidr"
value = "10.0.0.0/8"
action = "direct"

[[routing.rules]]
type = "ip_cidr"
value = "172.16.0.0/12"
action = "direct"

[[routing.rules]]
type = "ip_cidr"
value = "192.168.0.0/16"
action = "direct"

[[routing.rules]]
type = "ip_cidr"
value = "127.0.0.0/8"
action = "direct"

[log]
level = "info,tun_adapter::socks5=debug"
format = "pretty"

[bypass]
# proxy-remote 真实 IP,需要排除路由。
# 必须与 proxy-local 的 proxy.yml 中 remoteServers[].host 保持一致,
# 否则 proxy-local 连接 proxy-remote 的流量会被 utun9 劫持成环路,导致全网不通。
proxy_remote_ips = ["54.234.196.30"]
# 额外排除的网段(不进 TUN 的网段)
extra_cidrs = ["10.0.0.0/8", "11.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"]
# DNS bypass:这些 DNS 服务器的流量不走 TUN(供 proxy-local 直连做真实 DNS 解析)
# 注意:内网 DNS (11.11.11.11/12) 已通过 extra_cidrs 中的 11.0.0.0/8 覆盖
# 注意:必须和 start-tun.sh 的 DNS_SERVERS/DNS_FALLBACK 保持一致(114 主、223 兜底)。
dns_bypass_ips = ["114.114.114.114", "223.5.5.5"]

[intranet_dns]
# 内网 DNS 服务器(用于解析内网域名,流量走 bypass 不经过 TUN)
servers = ["11.11.11.11", "11.11.11.12"]
# 需要走内网 DNS 解析的域名后缀(会在 /etc/resolver/ 下创建分流规则)
domains = ["sankuai.com", "meituan.com", "sankuai.info", "neixin.cn", "dianping.com", "meituan.net"]
Empty file.
Binary file added desktop/src-tauri/resources/tun-adapter
Binary file not shown.
Loading