From 825c7373a742e4bbfcaca6d3fa05cca725368155 Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 11 Dec 2020 10:16:15 -0500 Subject: [PATCH] Filter out zero addresses in arp --- mobile/src/main/java/be/mygod/vpnhotspot/net/IpNeighbour.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/IpNeighbour.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/IpNeighbour.kt index 07f514ae..03139ecc 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/IpNeighbour.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/IpNeighbour.kt @@ -79,11 +79,12 @@ data class IpNeighbour(val ip: InetAddress, val dev: String, val lladdr: MacAddr val list = arp() .asSequence() .filter { parseNumericAddress(it[ARP_IP_ADDRESS]) == ip && it[ARP_DEVICE] in devs } - .map { it[ARP_HW_ADDRESS] } + .map { MacAddressCompat.fromString(it[ARP_HW_ADDRESS]) } + .filter { it != MacAddressCompat.ALL_ZEROS_ADDRESS } .distinct() .toList() when (list.size) { - 1 -> lladdr = MacAddressCompat.fromString(list.single()) + 1 -> lladdr = list.single() 0 -> { } else -> throw IllegalArgumentException("Unexpected output in arp: ${list.joinToString()}") }