feat: Direct AP 直连提速 + 剔除虚拟网卡 + 版本号提到 0.4.9 便于确认构建
三项一起处理。 1. 所有 PC→手机的二维码页面都有防火墙放行 「Android → 电脑」页在dec132c已加,「电脑 → Android」页在7b18c6a补上,两处都是「防火墙面板 + 二维码广播的地址」并在启动时自动检测。 本次把版本号从 0.4.8 提到 0.4.9:此前用户反馈"看不到防火墙功能", 实为未拉取新提交,而界面上没有任何可据以判断构建新旧的标识。 2. Direct AP 下先直连网关,UDP 发现退为兜底 Direct AP 场景里网关必然就是那台电脑——手机的 IP 正是它的 DHCP 发的。 此前却把阻塞式 UDP 发现排在最前,白白等掉一两秒才开始真正能成功的 那一步。现在配网一就绪立刻并发探测「网关 + 二维码携带的地址」 (400ms 连接 / 600ms 读取),不通才回落到 UDP 广播与子网扫描。 3. Direct AP 下彻底剔除虚拟网卡地址 二维码只放得下 4 个地址,而实测机器上有 192.168.30.1、192.168.31.1、 172.21.96.1 三个 VMware/Hyper-V/WSL 地址。上一版只做降权,名额紧张时 救不了场。Direct AP 启用时改为直接剔除——此刻手机连的是 AP 网段, 这些地址永远到不了,占着名额纯属浪费。 新增 is_virtual_endpoint(),对解析不了的字符串一律不判为虚拟, 避免误删真实地址。 cargo test 51/51。Kotlin 侧本机无法编译,仅结构检查。
This commit is contained in:
@@ -661,26 +661,42 @@ class MainActivity : ComponentActivity() {
|
||||
if (connectedBaseUrl != null) return@available
|
||||
transferExecutor.execute {
|
||||
if (attempt != pairConnectionAttempt) return@execute
|
||||
runOnUiThread { updateConnectingStatus("网络路由已就绪 · 正在 UDP 快速发现电脑…") }
|
||||
val discovered = UploadClient.discoverUdp(
|
||||
val gateways = wifiConnector.gatewayEndpoints(network, pair.port)
|
||||
|
||||
// 先直接打网关。Direct AP 场景下网关**必然**就是那台电脑
|
||||
// (手机的 IP 是电脑的 DHCP 发的),根本不需要先做发现。
|
||||
// 此前把阻塞式 UDP 发现排在最前,白白等掉一两秒才开始
|
||||
// 真正能成功的那一步。
|
||||
runOnUiThread { updateConnectingStatus("网络已就绪 · 正在直连网关…") }
|
||||
val direct = UploadClient.probeEndpoints(
|
||||
network = network,
|
||||
pairing = pair,
|
||||
hosts = wifiConnector.discoveryHosts(network),
|
||||
deviceName = receiverDeviceLabel,
|
||||
endpoints = (gateways + pair.endpoints).distinct(),
|
||||
connectMs = 400,
|
||||
readMs = 600,
|
||||
)
|
||||
runOnUiThread {
|
||||
updateConnectingStatus(
|
||||
if (discovered != null) "已通过 UDP 找到电脑 · 正在验证接收服务…"
|
||||
else "UDP 未响应 · 正在并行探测网关与本地 IP…"
|
||||
|
||||
// 直连不通才退回发现流程:UDP 广播 → 子网扫描
|
||||
var discovered: String? = null
|
||||
var subnet: List<String> = emptyList()
|
||||
if (direct == null) {
|
||||
runOnUiThread { updateConnectingStatus("网关未应答 · 正在 UDP 快速发现电脑…") }
|
||||
discovered = UploadClient.discoverUdp(
|
||||
network = network,
|
||||
pairing = pair,
|
||||
hosts = wifiConnector.discoveryHosts(network),
|
||||
)
|
||||
}
|
||||
val gateways = wifiConnector.gatewayEndpoints(network, pair.port)
|
||||
val subnet = wifiConnector.subnetEndpoints(network, pair.port)
|
||||
if (discovered == null) {
|
||||
subnet = wifiConnector.subnetEndpoints(network, pair.port)
|
||||
runOnUiThread {
|
||||
updateConnectingStatus("正在并行探测网关;必要时自动扫描当前 QFT 子网…")
|
||||
updateConnectingStatus(
|
||||
if (discovered != null) "已通过 UDP 找到电脑 · 正在验证接收服务…"
|
||||
else "正在并行探测网关;必要时自动扫描当前 QFT 子网…"
|
||||
)
|
||||
}
|
||||
}
|
||||
val base = UploadClient.probeRobust(
|
||||
|
||||
val base = direct ?: UploadClient.probeRobust(
|
||||
network = network,
|
||||
pairing = pair,
|
||||
deviceName = receiverDeviceLabel,
|
||||
|
||||
Reference in New Issue
Block a user