mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
Fix: refactor tun implement
This commit is contained in:
@@ -217,6 +217,7 @@ class TunService : VpnService(), CoroutineScope by CoroutineScope(Dispatchers.De
|
||||
fd = establish()?.detachFd()
|
||||
?: throw NullPointerException("Establish VPN rejected by system"),
|
||||
mtu = TUN_MTU,
|
||||
gateway = "$TUN_GATEWAY/$TUN_SUBNET_PREFIX",
|
||||
dns = if (store.dnsHijacking) NET_ANY else TUN_DNS,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ class TunModule(private val vpn: VpnService) : Module<Unit>(vpn) {
|
||||
data class TunDevice(
|
||||
val fd: Int,
|
||||
val mtu: Int,
|
||||
val dns: String
|
||||
val gateway: String,
|
||||
val dns: String,
|
||||
)
|
||||
|
||||
private val connectivity = service.getSystemService<ConnectivityManager>()!!
|
||||
@@ -56,6 +57,7 @@ class TunModule(private val vpn: VpnService) : Module<Unit>(vpn) {
|
||||
Clash.startTun(
|
||||
fd = device.fd,
|
||||
mtu = device.mtu,
|
||||
gateway = device.gateway,
|
||||
dns = device.dns,
|
||||
markSocket = vpn::protect,
|
||||
querySocketUid = this::queryUid
|
||||
|
||||
Reference in New Issue
Block a user