1. increased buffer size

This commit is contained in:
vadym 2020-08-05 14:42:13 -07:00
parent 445683b87e
commit 53c945430d

View File

@ -128,7 +128,7 @@ class YggdrasilTunService : VpnService() {
val job = SupervisorJob() val job = SupervisorJob()
scope = CoroutineScope(Dispatchers.Default + job) scope = CoroutineScope(Dispatchers.Default + job)
scope!!.launch { scope!!.launch {
val buffer = ByteArray(1024) val buffer = ByteArray(MAX_PACKET_SIZE)
while (!isClosed) { while (!isClosed) {
readPacketsFromTun(yggConduitEndpoint, buffer) readPacketsFromTun(yggConduitEndpoint, buffer)
} }
@ -215,7 +215,7 @@ class YggdrasilTunService : VpnService() {
private fun readPacketsFromTun(yggConduitEndpoint: ConduitEndpoint, buffer: ByteArray) { private fun readPacketsFromTun(yggConduitEndpoint: ConduitEndpoint, buffer: ByteArray) {
try { try {
// Read the outgoing packet from the input stream. // Read the outgoing packet from the input stream.
val length = tunInputStream.buffered().read(buffer) val length = tunInputStream.read(buffer)
if(length>0) { if(length>0) {
yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1))) yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1)))
} }