mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
support set tun stack
This commit is contained in:
@@ -218,6 +218,7 @@ class TunService : VpnService(), CoroutineScope by CoroutineScope(Dispatchers.De
|
||||
TunModule.TunDevice(
|
||||
fd = establish()?.detachFd()
|
||||
?: throw NullPointerException("Establish VPN rejected by system"),
|
||||
stack = store.tunStackMode,
|
||||
gateway = "$TUN_GATEWAY/$TUN_SUBNET_PREFIX" + if (store.allowIpv6) ",$TUN_GATEWAY6/$TUN_SUBNET_PREFIX6" else "",
|
||||
portal = TUN_PORTAL + if (store.allowIpv6) ",$TUN_PORTAL6" else "",
|
||||
dns = if (store.dnsHijacking) NET_ANY else (TUN_DNS + if (store.allowIpv6) ",$TUN_DNS6" else ""),
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.security.SecureRandom
|
||||
class TunModule(private val vpn: VpnService) : Module<Unit>(vpn) {
|
||||
data class TunDevice(
|
||||
val fd: Int,
|
||||
var stack: String,
|
||||
val gateway: String,
|
||||
val portal: String,
|
||||
val dns: String,
|
||||
@@ -56,6 +57,7 @@ class TunModule(private val vpn: VpnService) : Module<Unit>(vpn) {
|
||||
fun attach(device: TunDevice) {
|
||||
Clash.startTun(
|
||||
fd = device.fd,
|
||||
stack = device.stack,
|
||||
gateway = device.gateway,
|
||||
portal = device.portal,
|
||||
dns = device.dns,
|
||||
|
||||
@@ -56,6 +56,11 @@ class ServiceStore(context: Context) {
|
||||
defaultValue = false
|
||||
)
|
||||
|
||||
var tunStackMode by store.string(
|
||||
key = "tun_stack_mode",
|
||||
defaultValue = "system"
|
||||
)
|
||||
|
||||
var dynamicNotification by store.boolean(
|
||||
key = "dynamic_notification",
|
||||
defaultValue = true
|
||||
|
||||
Reference in New Issue
Block a user