1. buffered read fix

This commit is contained in:
vadym 2020-08-05 14:25:14 -07:00
parent b2b6f2c8ef
commit 445683b87e

View File

@ -215,8 +215,10 @@ 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.read(buffer) val length = tunInputStream.buffered().read(buffer)
yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1))) if(length>0) {
yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1)))
}
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printStackTrace()
} }