Fixed warnings, added implementations
parent
887729faf8
commit
f2aeec156b
|
@ -564,7 +564,7 @@ object IPv4 {
|
|||
}
|
||||
|
||||
val x = ln(end - start + 1.toDouble()) / ln(2.0)
|
||||
val maxDiff = (32 - floor(x)).toByte()
|
||||
val maxDiff = (32 - floor(x)).toInt().toByte()
|
||||
if (maxsize < maxDiff) {
|
||||
maxsize = maxDiff
|
||||
}
|
||||
|
|
|
@ -16,7 +16,15 @@
|
|||
package dorkbox.netUtil
|
||||
|
||||
import java.io.IOException
|
||||
import java.net.*
|
||||
import java.net.InetAddress
|
||||
import java.net.InetSocketAddress
|
||||
import java.net.NetworkInterface
|
||||
import java.net.ServerSocket
|
||||
import java.net.Socket
|
||||
import java.net.SocketAddress
|
||||
import java.net.SocketException
|
||||
import java.net.SocketPermission
|
||||
import java.net.UnknownHostException
|
||||
import java.nio.channels.DatagramChannel
|
||||
import java.nio.channels.ServerSocketChannel
|
||||
import java.nio.channels.SocketChannel
|
||||
|
@ -35,6 +43,8 @@ import java.util.*
|
|||
*/
|
||||
object SocketUtils {
|
||||
private val EMPTY = Collections.enumeration(emptyList<Any>())
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun <T> empty(): Enumeration<T> {
|
||||
return EMPTY as Enumeration<T>
|
||||
}
|
||||
|
|
|
@ -1,21 +1,32 @@
|
|||
package dorkbox.netUtil
|
||||
|
||||
import dorkbox.executor.Executor
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
object VirtualEth {
|
||||
fun add(host: String?, guest: String?) {
|
||||
// ShellExecutor.Companion.run("/sbin/ip", "link add name " + host + " type veth peer name " + guest);
|
||||
throw RuntimeException("NOT IMPL.")
|
||||
fun add(host: String, guest: String) {
|
||||
if (Common.OS_LINUX) {
|
||||
Executor().command("/sbin/ip", "link", "add", "name", host, "type", "veth", "peer", "name", guest).startBlocking()
|
||||
} else {
|
||||
throw RuntimeException("NOT IMPL.")
|
||||
}
|
||||
}
|
||||
|
||||
fun delete(host: String?) {
|
||||
// ShellExecutor.Companion.run("/sbin/ip", "link del " + host);
|
||||
throw RuntimeException("NOT IMPL.")
|
||||
fun delete(host: String) {
|
||||
if (Common.OS_LINUX) {
|
||||
Executor().command("/sbin/ip", "link", "del", host).startBlocking()
|
||||
} else {
|
||||
throw RuntimeException("NOT IMPL.")
|
||||
}
|
||||
}
|
||||
|
||||
fun assignNameSpace(nameSpace: String?, guest: String?) {
|
||||
// ShellExecutor.Companion.run("/sbin/ip", "link set " + guest + " netns " + nameSpace);
|
||||
throw RuntimeException("NOT IMPL.")
|
||||
fun assignNameSpace(nameSpace: String, guest: String) {
|
||||
if (Common.OS_LINUX) {
|
||||
Executor().command("/sbin/ip", "link", "set", "guest", "netns", nameSpace).startBlocking()
|
||||
} else {
|
||||
throw RuntimeException("NOT IMPL.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue