Fixed bug with windows OS detection

connection_type_change
Robinson 2021-04-06 01:27:37 +02:00
parent 2164890bd0
commit 546ed90ec2
1 changed files with 7 additions and 2 deletions

View File

@ -3,6 +3,7 @@
package dorkbox.netUtil
import mu.KotlinLogging
import java.net.InetSocketAddress
import java.security.AccessController
import java.security.PrivilegedAction
@ -24,13 +25,13 @@ internal object Common {
}
} catch (ignored: java.lang.Exception) {
"linux"
}
}.toLowerCase()
if (osName.startsWith("mac") || osName.startsWith("darwin")) {
OS_LINUX = false
OS_WINDOWS = false
OS_MAC = true
} else if (osName.startsWith("windows")) {
} else if (osName.startsWith("win")) {
OS_LINUX = false
OS_WINDOWS = true
OS_MAC = false
@ -106,4 +107,8 @@ internal object Common {
-1
}
}
fun socketAddress(hostname: String, port: Int): InetSocketAddress {
return AccessController.doPrivileged<InetSocketAddress>(PrivilegedAction { InetSocketAddress(hostname, port) })
}
}