mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2025-01-22 16:06:30 +00:00
3. fixed high CPU load after switch-off. prevent NPE.
This commit is contained in:
parent
234dcbef77
commit
85e27ff7e1
@ -88,12 +88,11 @@ class YggdrasilTunService : VpnService() {
|
|||||||
address = ygg.addressString
|
address = ygg.addressString
|
||||||
|
|
||||||
var builder = Builder()
|
var builder = Builder()
|
||||||
.addAddress(address, 7)
|
.addAddress(address!!, 7)
|
||||||
.allowFamily(OsConstants.AF_INET)
|
.allowFamily(OsConstants.AF_INET)
|
||||||
.allowBypass()
|
.allowBypass()
|
||||||
.setMtu(MAX_PACKET_SIZE)
|
.setMtu(MAX_PACKET_SIZE)
|
||||||
if (dns.size > 0) {
|
if (dns.size > 0) {
|
||||||
builder.addDnsServer(address)
|
|
||||||
for (d in dns) {
|
for (d in dns) {
|
||||||
builder.addDnsServer(d.address)
|
builder.addDnsServer(d.address)
|
||||||
}
|
}
|
||||||
@ -272,6 +271,7 @@ class YggdrasilTunService : VpnService() {
|
|||||||
val networks = cm.allNetworks
|
val networks = cm.allNetworks
|
||||||
for (network in networks) {
|
for (network in networks) {
|
||||||
val linkProperties = cm.getLinkProperties(network)
|
val linkProperties = cm.getLinkProperties(network)
|
||||||
|
if(linkProperties!=null) {
|
||||||
val routes = linkProperties.routes
|
val routes = linkProperties.routes
|
||||||
for (route in routes) {
|
for (route in routes) {
|
||||||
if (route.isDefaultRoute && route.gateway is Inet6Address) {
|
if (route.isDefaultRoute && route.gateway is Inet6Address) {
|
||||||
@ -279,6 +279,7 @@ class YggdrasilTunService : VpnService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user