diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt index 60af9df..97adb9e 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt @@ -215,8 +215,10 @@ class YggdrasilTunService : VpnService() { private fun readPacketsFromTun(yggConduitEndpoint: ConduitEndpoint, buffer: ByteArray) { try { // Read the outgoing packet from the input stream. - val length = tunInputStream.read(buffer) - yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1))) + val length = tunInputStream.buffered().read(buffer) + if(length>0) { + yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1))) + } } catch (e: IOException) { e.printStackTrace() }