Skip to content

Commit 14849d2

Browse files
committed
Silence some not-important VPN error reports
If the network is offline, we don't need to know about it when it comes back. We also explicitly don't support IPv6, and that's OK (for now), that's not an error as such.
1 parent 5e21c45 commit 14849d2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

app/src/main/java/tech/httptoolkit/android/ProxyVpnRunnable.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import tech.httptoolkit.android.vpn.SessionHandler
88
import tech.httptoolkit.android.vpn.SessionManager
99
import tech.httptoolkit.android.vpn.socket.SocketNIODataService
1010
import io.sentry.Sentry
11+
import tech.httptoolkit.android.vpn.transport.PacketHeaderException
1112
import java.io.FileInputStream
1213
import java.io.FileOutputStream
1314
import java.io.InterruptedIOException
15+
import java.net.ConnectException
1416
import java.net.InetSocketAddress
1517
import java.nio.ByteBuffer
1618

@@ -78,9 +80,16 @@ class ProxyVpnRunnable(
7880
packet.limit(length)
7981
handler.handlePacket(packet)
8082
} catch (e: Exception) {
81-
Sentry.capture(e)
82-
val errorMessage = e.message ?: e.toString()
83+
val errorMessage = (e.message ?: e.toString())
8384
Log.e(TAG, errorMessage)
85+
86+
val isIgnorable =
87+
(e is ConnectException && errorMessage == "Network is unreachable") ||
88+
(e is PacketHeaderException && errorMessage.contains("IP version should be 4 but was 6"))
89+
90+
if (!isIgnorable) {
91+
Sentry.capture(e)
92+
}
8493
}
8594

8695
packet.clear()

0 commit comments

Comments
 (0)