Updated kotlin + dependencies
parent
f035f5e00b
commit
573098c5a4
|
@ -110,7 +110,7 @@ dependencies {
|
|||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("ch.qos.logback:logback-classic:1.3.0-alpha4")
|
||||
testImplementation("com.dorkbox:Utilities:1.16")
|
||||
testImplementation("com.dorkbox:Utilities:1.22")
|
||||
}
|
||||
|
||||
publishToSonatype {
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.net.InetAddress
|
|||
import java.net.InetSocketAddress
|
||||
import java.security.AccessController
|
||||
import java.security.PrivilegedAction
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Network Utilities. MAC, IP, NameSpace, etc
|
||||
|
@ -31,7 +32,7 @@ internal object Common {
|
|||
}
|
||||
} catch (ignored: java.lang.Exception) {
|
||||
"linux"
|
||||
}.toLowerCase()
|
||||
}.lowercase(Locale.getDefault())
|
||||
|
||||
if (osName.startsWith("mac") || osName.startsWith("darwin")) {
|
||||
OS_LINUX = false
|
||||
|
@ -56,7 +57,7 @@ internal object Common {
|
|||
|
||||
fun getBoolean(property: String, defaultValue: Boolean): Boolean {
|
||||
var value: String = System.getProperty(property, defaultValue.toString()) ?: return defaultValue
|
||||
value = value.trim().toLowerCase()
|
||||
value = value.trim().lowercase(Locale.getDefault())
|
||||
|
||||
if (value.isEmpty()) {
|
||||
return defaultValue
|
||||
|
@ -71,29 +72,29 @@ internal object Common {
|
|||
else defaultValue
|
||||
}
|
||||
|
||||
private val HEX2B: IntArray = IntArray('f'.toInt()+1).apply {
|
||||
set('0'.toInt(), 0)
|
||||
set('1'.toInt(), 1)
|
||||
set('2'.toInt(), 2)
|
||||
set('3'.toInt(), 3)
|
||||
set('4'.toInt(), 4)
|
||||
set('5'.toInt(), 5)
|
||||
set('6'.toInt(), 6)
|
||||
set('7'.toInt(), 7)
|
||||
set('8'.toInt(), 8)
|
||||
set('9'.toInt(), 9)
|
||||
set('A'.toInt(), 10)
|
||||
set('B'.toInt(), 11)
|
||||
set('C'.toInt(), 12)
|
||||
set('D'.toInt(), 13)
|
||||
set('E'.toInt(), 14)
|
||||
set('F'.toInt(), 15)
|
||||
set('a'.toInt(), 10)
|
||||
set('b'.toInt(), 11)
|
||||
set('c'.toInt(), 12)
|
||||
set('d'.toInt(), 13)
|
||||
set('e'.toInt(), 14)
|
||||
set('f'.toInt(), 15)
|
||||
private val HEX2B: IntArray = IntArray('f'.code + 1).apply {
|
||||
set('0'.code, 0)
|
||||
set('1'.code, 1)
|
||||
set('2'.code, 2)
|
||||
set('3'.code, 3)
|
||||
set('4'.code, 4)
|
||||
set('5'.code, 5)
|
||||
set('6'.code, 6)
|
||||
set('7'.code, 7)
|
||||
set('8'.code, 8)
|
||||
set('9'.code, 9)
|
||||
set('A'.code, 10)
|
||||
set('B'.code, 11)
|
||||
set('C'.code, 12)
|
||||
set('D'.code, 13)
|
||||
set('E'.code, 14)
|
||||
set('F'.code, 15)
|
||||
set('a'.code, 10)
|
||||
set('b'.code, 11)
|
||||
set('c'.code, 12)
|
||||
set('d'.code, 13)
|
||||
set('e'.code, 14)
|
||||
set('f'.code, 15)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,7 +109,7 @@ internal object Common {
|
|||
fun decodeHexNibble(c: Char): Int {
|
||||
// Character.digit() is not used here, as it addresses a larger
|
||||
// set of characters (both ASCII and full-width latin letters).
|
||||
val index = c.toInt()
|
||||
val index = c.code
|
||||
|
||||
return try {
|
||||
HEX2B[index]
|
||||
|
|
|
@ -19,7 +19,11 @@ package dorkbox.netUtil
|
|||
|
||||
import java.io.IOException
|
||||
import java.io.Writer
|
||||
import java.net.*
|
||||
import java.net.Inet4Address
|
||||
import java.net.InetAddress
|
||||
import java.net.NetworkInterface
|
||||
import java.net.SocketException
|
||||
import java.net.UnknownHostException
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.ln
|
||||
import kotlin.math.pow
|
||||
|
@ -783,11 +787,11 @@ object IPv4 {
|
|||
@Throws(Exception::class)
|
||||
fun writeString(ipAddress: Int, writer: Writer) {
|
||||
writer.write((ipAddress shr 24 and 0xFF).toString())
|
||||
writer.write('.'.toInt())
|
||||
writer.write('.'.code)
|
||||
writer.write((ipAddress shr 16 and 0xFF).toString())
|
||||
writer.write('.'.toInt())
|
||||
writer.write('.'.code)
|
||||
writer.write((ipAddress shr 8 and 0xFF).toString())
|
||||
writer.write('.'.toInt())
|
||||
writer.write('.'.code)
|
||||
writer.write((ipAddress and 0xFF).toString())
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.math.BigInteger
|
|||
import java.net.InetAddress
|
||||
import java.net.NetworkInterface
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
import java.util.regex.*
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -332,8 +332,7 @@ object Mac {
|
|||
buf.append('0')
|
||||
}
|
||||
|
||||
buf.append(Integer.toHexString(b.toInt() and 0xFF)
|
||||
.toUpperCase())
|
||||
buf.append(Integer.toHexString(b.toInt() and 0xFF).uppercase(Locale.ENGLISH))
|
||||
}
|
||||
return buf.toString()
|
||||
}
|
||||
|
|
|
@ -58,6 +58,6 @@ object DefaultHostsFileResolver {
|
|||
}
|
||||
|
||||
private fun normalize(inetHost: String): String {
|
||||
return inetHost.toLowerCase(Locale.ENGLISH)
|
||||
return inetHost.lowercase(Locale.ENGLISH)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,13 +20,18 @@ import dorkbox.netUtil.Common.OS_WINDOWS
|
|||
import dorkbox.netUtil.Common.logger
|
||||
import dorkbox.netUtil.IPv4
|
||||
import dorkbox.netUtil.IPv6
|
||||
import java.io.*
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import java.io.Reader
|
||||
import java.net.Inet4Address
|
||||
import java.net.Inet6Address
|
||||
import java.net.InetAddress
|
||||
import java.nio.charset.Charset
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
import java.util.regex.*
|
||||
|
||||
/**
|
||||
* A parser for hosts files.
|
||||
|
@ -162,7 +167,7 @@ object HostsFileParser {
|
|||
// loop over hostname and aliases, skip invalid IP
|
||||
for (i in 1 until lineParts.size) {
|
||||
val hostname = lineParts[i]
|
||||
val hostnameLower = hostname.toLowerCase(Locale.ENGLISH)
|
||||
val hostnameLower = hostname.lowercase(Locale.ENGLISH)
|
||||
val address = InetAddress.getByAddress(hostname, ipBytes)
|
||||
if (address is Inet4Address) {
|
||||
val previous = ipv4Entries.put(hostnameLower, address)
|
||||
|
|
Loading…
Reference in New Issue