Catch stupid runtimeexceptions

This commit is contained in:
Mygod
2020-09-12 04:12:28 +08:00
parent c1a5f33d00
commit 45ea7a8bf3

View File

@@ -20,6 +20,7 @@ import kotlinx.coroutines.CancellationException
import timber.log.Timber import timber.log.Timber
import java.io.BufferedWriter import java.io.BufferedWriter
import java.io.IOException import java.io.IOException
import java.lang.RuntimeException
import java.net.Inet4Address import java.net.Inet4Address
import java.net.InetAddress import java.net.InetAddress
import java.net.NetworkInterface import java.net.NetworkInterface
@@ -206,11 +207,13 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh
val size = dest.address.size val size = dest.address.size
var bestRoute: RouteInfo? = null var bestRoute: RouteInfo? = null
for (route in routes!!) { for (route in routes!!) {
if (route.destination.rawAddress.size == size && if (route.destination.rawAddress.size == size && (bestRoute == null ||
(bestRoute == null || bestRoute.destination.prefixLength < route.destination.prefixLength)) {
bestRoute.destination.prefixLength < route.destination.prefixLength) && try {
route.matches(dest)) { if (route.matches(dest)) bestRoute = route
bestRoute = route } catch (e: RuntimeException) {
Timber.w(e)
}
} }
} }
dest to bestRoute?.`interface` dest to bestRoute?.`interface`