From 8c221d48e95e8d99d99a6e04b9af8de5efedbe12 Mon Sep 17 00:00:00 2001 From: Mygod Date: Wed, 4 Nov 2020 08:47:21 +0800 Subject: [PATCH] Check networkPrefixLength on stupid devices --- mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 57847a4a..6aff14f7 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -135,7 +135,7 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh private val hostAddress = try { val iface = NetworkInterface.getByName(downstream) ?: error("iface not found") - val addresses = iface.interfaceAddresses!!.filter { it.address is Inet4Address } + val addresses = iface.interfaceAddresses!!.filter { it.address is Inet4Address && it.networkPrefixLength <= 32 } if (addresses.size > 1) error("More than one addresses was found: $addresses") addresses.first() } catch (e: Exception) {