Update core (sing-box v1.7.5)
This commit is contained in:
@@ -8,6 +8,7 @@ import android.net.VpnService
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import com.hiddify.hiddify.constant.PerAppProxyMode
|
import com.hiddify.hiddify.constant.PerAppProxyMode
|
||||||
|
import com.hiddify.hiddify.ktx.toIpPrefix
|
||||||
import io.nekohasekai.libbox.TunOptions
|
import io.nekohasekai.libbox.TunOptions
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
@@ -31,6 +32,7 @@ class VPNService : VpnService(), PlatformInterfaceWrapper {
|
|||||||
}
|
}
|
||||||
return service.onBind(intent)
|
return service.onBind(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
service.onDestroy()
|
service.onDestroy()
|
||||||
}
|
}
|
||||||
@@ -62,42 +64,64 @@ class VPNService : VpnService(), PlatformInterfaceWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val inet4Address = options.inet4Address
|
val inet4Address = options.inet4Address
|
||||||
if (inet4Address.hasNext()) {
|
while (inet4Address.hasNext()) {
|
||||||
while (inet4Address.hasNext()) {
|
val address = inet4Address.next()
|
||||||
val address = inet4Address.next()
|
builder.addAddress(address.address(), address.prefix())
|
||||||
builder.addAddress(address.address, address.prefix)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val inet6Address = options.inet6Address
|
val inet6Address = options.inet6Address
|
||||||
if (inet6Address.hasNext()) {
|
while (inet6Address.hasNext()) {
|
||||||
while (inet6Address.hasNext()) {
|
val address = inet6Address.next()
|
||||||
val address = inet6Address.next()
|
builder.addAddress(address.address(), address.prefix())
|
||||||
builder.addAddress(address.address, address.prefix)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.autoRoute) {
|
if (options.autoRoute) {
|
||||||
builder.addDnsServer(options.dnsServerAddress)
|
builder.addDnsServer(options.dnsServerAddress)
|
||||||
|
|
||||||
val inet4RouteAddress = options.inet4RouteAddress
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
if (inet4RouteAddress.hasNext()) {
|
val inet4RouteAddress = options.inet4RouteAddress
|
||||||
while (inet4RouteAddress.hasNext()) {
|
if (inet4RouteAddress.hasNext()) {
|
||||||
val address = inet4RouteAddress.next()
|
while (inet4RouteAddress.hasNext()) {
|
||||||
builder.addRoute(address.address, address.prefix)
|
builder.addRoute(inet4RouteAddress.next().toIpPrefix())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
builder.addRoute("0.0.0.0", 0)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
builder.addRoute("0.0.0.0", 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
val inet6RouteAddress = options.inet6RouteAddress
|
val inet6RouteAddress = options.inet6RouteAddress
|
||||||
if (inet6RouteAddress.hasNext()) {
|
if (inet6RouteAddress.hasNext()) {
|
||||||
while (inet6RouteAddress.hasNext()) {
|
while (inet6RouteAddress.hasNext()) {
|
||||||
val address = inet6RouteAddress.next()
|
builder.addRoute(inet6RouteAddress.next().toIpPrefix())
|
||||||
builder.addRoute(address.address, address.prefix)
|
}
|
||||||
|
} else {
|
||||||
|
builder.addRoute("::", 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
val inet4RouteExcludeAddress = options.inet4RouteExcludeAddress
|
||||||
|
while (inet4RouteExcludeAddress.hasNext()) {
|
||||||
|
builder.excludeRoute(inet4RouteExcludeAddress.next().toIpPrefix())
|
||||||
|
}
|
||||||
|
|
||||||
|
val inet6RouteExcludeAddress = options.inet6RouteExcludeAddress
|
||||||
|
while (inet6RouteExcludeAddress.hasNext()) {
|
||||||
|
builder.excludeRoute(inet6RouteExcludeAddress.next().toIpPrefix())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
builder.addRoute("::", 0)
|
val inet4RouteAddress = options.inet4RouteRange
|
||||||
|
if (inet4RouteAddress.hasNext()) {
|
||||||
|
while (inet4RouteAddress.hasNext()) {
|
||||||
|
val address = inet4RouteAddress.next()
|
||||||
|
builder.addRoute(address.address(), address.prefix())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val inet6RouteAddress = options.inet6RouteRange
|
||||||
|
if (inet6RouteAddress.hasNext()) {
|
||||||
|
while (inet6RouteAddress.hasNext()) {
|
||||||
|
val address = inet6RouteAddress.next()
|
||||||
|
builder.addRoute(address.address(), address.prefix())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.perAppProxyEnabled) {
|
if (Settings.perAppProxyEnabled) {
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package com.hiddify.hiddify.ktx
|
package com.hiddify.hiddify.ktx
|
||||||
|
|
||||||
|
import android.net.IpPrefix
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
|
import io.nekohasekai.libbox.RoutePrefix
|
||||||
import io.nekohasekai.libbox.StringIterator
|
import io.nekohasekai.libbox.StringIterator
|
||||||
|
import java.net.InetAddress
|
||||||
|
|
||||||
fun StringIterator.toList(): List<String> {
|
fun StringIterator.toList(): List<String> {
|
||||||
return mutableListOf<String>().apply {
|
return mutableListOf<String>().apply {
|
||||||
@@ -9,3 +14,6 @@ fun StringIterator.toList(): List<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||||
|
fun RoutePrefix.toIpPrefix() = IpPrefix(InetAddress.getByName(address()), prefix())
|
||||||
@@ -1 +1 @@
|
|||||||
core.version=0.9.0
|
core.version=0.9.1
|
||||||
2
libcore
2
libcore
Submodule libcore updated: 4099f968e2...8e9d5239f4
Reference in New Issue
Block a user