Fixed bug with windows OS detection
This commit is contained in:
parent
2164890bd0
commit
546ed90ec2
|
@ -3,6 +3,7 @@
|
||||||
package dorkbox.netUtil
|
package dorkbox.netUtil
|
||||||
|
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
|
import java.net.InetSocketAddress
|
||||||
import java.security.AccessController
|
import java.security.AccessController
|
||||||
import java.security.PrivilegedAction
|
import java.security.PrivilegedAction
|
||||||
|
|
||||||
|
@ -24,13 +25,13 @@ internal object Common {
|
||||||
}
|
}
|
||||||
} catch (ignored: java.lang.Exception) {
|
} catch (ignored: java.lang.Exception) {
|
||||||
"linux"
|
"linux"
|
||||||
}
|
}.toLowerCase()
|
||||||
|
|
||||||
if (osName.startsWith("mac") || osName.startsWith("darwin")) {
|
if (osName.startsWith("mac") || osName.startsWith("darwin")) {
|
||||||
OS_LINUX = false
|
OS_LINUX = false
|
||||||
OS_WINDOWS = false
|
OS_WINDOWS = false
|
||||||
OS_MAC = true
|
OS_MAC = true
|
||||||
} else if (osName.startsWith("windows")) {
|
} else if (osName.startsWith("win")) {
|
||||||
OS_LINUX = false
|
OS_LINUX = false
|
||||||
OS_WINDOWS = true
|
OS_WINDOWS = true
|
||||||
OS_MAC = false
|
OS_MAC = false
|
||||||
|
@ -106,4 +107,8 @@ internal object Common {
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun socketAddress(hostname: String, port: Int): InetSocketAddress {
|
||||||
|
return AccessController.doPrivileged<InetSocketAddress>(PrivilegedAction { InetSocketAddress(hostname, port) })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue