Fix getByName returns null
This commit is contained in:
@@ -168,5 +168,5 @@ fun if_nametoindex(ifname: String) = if (Build.VERSION.SDK_INT >= 26) {
|
|||||||
} else try {
|
} else try {
|
||||||
File("/sys/class/net/$ifname/ifindex").inputStream().bufferedReader().use { it.readLine().toInt() }
|
File("/sys/class/net/$ifname/ifindex").inputStream().bufferedReader().use { it.readLine().toInt() }
|
||||||
} catch (_: FileNotFoundException) {
|
} catch (_: FileNotFoundException) {
|
||||||
NetworkInterface.getByName(ifname).index
|
NetworkInterface.getByName(ifname)?.index ?: 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user