NetworkUtils/src/dorkbox/netUtil/Route.kt

26 lines
549 B
Kotlin
Raw Normal View History

package dorkbox.netUtil
import dorkbox.executor.Executor
/**
*
*/
object Route {
/**
* Gets the version number.
*/
2021-05-02 22:36:50 +02:00
const val version = "2.8"
fun flush() {
Executor.run("/sbin/ip", "route", "flush", "cache")
}
fun add(targetIpAndCidr: String, hostIP: String, hostInterface: String) {
if (Common.OS_LINUX) {
Executor.run("/sbin/ip", "route", "add", targetIpAndCidr, "via", hostIP, "dev", hostInterface);
} else {
throw RuntimeException("NOT IMPL.")
}
}
}