From df0733f6b66d62c52c55c864a155a07dff3a52c7 Mon Sep 17 00:00:00 2001 From: vadym Date: Wed, 5 Aug 2020 10:59:00 -0700 Subject: [PATCH] 1. set blocking read --- .../io/github/chronosx88/yggdrasil/YggdrasilTunService.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 f71d2fd..5380900 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/YggdrasilTunService.kt @@ -89,6 +89,7 @@ class YggdrasilTunService : VpnService() { .addAddress(address!!, 7) .allowFamily(OsConstants.AF_INET) .allowBypass() + .setBlocking(true) .setMtu(MAX_PACKET_SIZE) } else { Builder() @@ -227,11 +228,7 @@ class YggdrasilTunService : VpnService() { try { // Read the outgoing packet from the input stream. val length = tunInputStream?.read(buffer) ?: 1 - if (length > 0){ - yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1))) - } else { - Thread.sleep(10) - } + yggConduitEndpoint.send(buffer.sliceArray(IntRange(0, length - 1))) } catch (e: IOException) { e.printStackTrace() }