add tun start failure detect
This commit is contained in:
3 files changed
+12
-3
No files matched your search
+2
-2
@@ -10,8 +10,8 @@ buildscript {
|
||||
this["gMinSdkVersion"] = 24
|
||||
this["gTargetSdkVersion"] = 29
|
||||
|
||||
this["gVersionCode"] = 10205
|
||||
this["gVersionName"] = "1.2.5"
|
||||
this["gVersionCode"] = 10206
|
||||
this["gVersionName"] = "1.2.6"
|
||||
|
||||
this["gKotlinVersion"] = kotlinVersion
|
||||
this["gKotlinCoroutineVersion"] = "1.3.5"
|
||||
|
||||
@@ -146,5 +146,11 @@ class TunService : VpnService(), CoroutineScope by MainScope() {
|
||||
(settings.get(ServiceSettings.ACCESS_CONTROL_PACKAGES) - packageName).toList()
|
||||
} else emptyList()
|
||||
}
|
||||
|
||||
override fun onCreateTunFailure() {
|
||||
reason = "Start VPN is rejected by the system"
|
||||
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ class TunModule(private val service: VpnService) : Module() {
|
||||
val dnsHijacking: Boolean
|
||||
val allowApplications: List<String>
|
||||
val disallowApplication: List<String>
|
||||
|
||||
fun onCreateTunFailure()
|
||||
}
|
||||
|
||||
var configure: Configure? = null
|
||||
@@ -62,7 +64,8 @@ class TunModule(private val service: VpnService) : Module() {
|
||||
builder.setMetered(false)
|
||||
}
|
||||
|
||||
val fd = builder.establish() ?: throw NullPointerException("Unable to create vpn")
|
||||
val fd = builder.establish()
|
||||
?: return@withContext c.onCreateTunFailure()
|
||||
|
||||
if (c.dnsHijacking) {
|
||||
Clash.startTunDevice(
|
||||
|
||||
Reference in new issue
Block a user