Fixed warnings, added implementations

connection_type_change
nathan 2020-08-18 22:34:13 +02:00
parent 887729faf8
commit f2aeec156b
3 changed files with 32 additions and 11 deletions

View File

@ -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
}

View File

@ -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>
}

View File

@ -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.")
}
}
}