From 45ea7a8bf3b9ea597d6ee65671a80b0578ed1ec9 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 12 Sep 2020 04:12:28 +0800 Subject: [PATCH] Catch stupid runtimeexceptions --- .../main/java/be/mygod/vpnhotspot/net/Routing.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt index ddec2f1d..bbeb5b71 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -20,6 +20,7 @@ import kotlinx.coroutines.CancellationException import timber.log.Timber import java.io.BufferedWriter import java.io.IOException +import java.lang.RuntimeException import java.net.Inet4Address import java.net.InetAddress import java.net.NetworkInterface @@ -206,11 +207,13 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh val size = dest.address.size var bestRoute: RouteInfo? = null for (route in routes!!) { - if (route.destination.rawAddress.size == size && - (bestRoute == null || - bestRoute.destination.prefixLength < route.destination.prefixLength) && - route.matches(dest)) { - bestRoute = route + if (route.destination.rawAddress.size == size && (bestRoute == null || + bestRoute.destination.prefixLength < route.destination.prefixLength)) { + try { + if (route.matches(dest)) bestRoute = route + } catch (e: RuntimeException) { + Timber.w(e) + } } } dest to bestRoute?.`interface`