mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2024-11-09 20:11:01 +00:00
1. set blocking read
This commit is contained in:
parent
a24e3ad645
commit
df0733f6b6
@ -89,6 +89,7 @@ class YggdrasilTunService : VpnService() {
|
|||||||
.addAddress(address!!, 7)
|
.addAddress(address!!, 7)
|
||||||
.allowFamily(OsConstants.AF_INET)
|
.allowFamily(OsConstants.AF_INET)
|
||||||
.allowBypass()
|
.allowBypass()
|
||||||
|
.setBlocking(true)
|
||||||
.setMtu(MAX_PACKET_SIZE)
|
.setMtu(MAX_PACKET_SIZE)
|
||||||
} else {
|
} else {
|
||||||
Builder()
|
Builder()
|
||||||
@ -227,11 +228,7 @@ class YggdrasilTunService : VpnService() {
|
|||||||
try {
|
try {
|
||||||
// Read the outgoing packet from the input stream.
|
// Read the outgoing packet from the input stream.
|
||||||
val length = tunInputStream?.read(buffer) ?: 1
|
val length = tunInputStream?.read(buffer) ?: 1
|
||||||
if (length > 0){
|
|
||||||
yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1)))
|
yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1)))
|
||||||
} else {
|
|
||||||
Thread.sleep(10)
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user