diff --git a/build.gradle.kts b/build.gradle.kts index a71bd44..7da0891 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,8 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { - kotlin("multiplatform") version "1.3.72" - kotlin("plugin.serialization") version "1.3.72" + kotlin("multiplatform") version "1.4.0" + kotlin("plugin.serialization") version "1.4.0" id("maven-publish") id("com.github.johnrengelman.shadow") version "5.2.0" } @@ -15,6 +15,7 @@ val serializationVersion: String by project repositories { mavenCentral() jcenter() + maven(url = "https://kotlin.bintray.com/kotlinx") } kotlin { @@ -54,15 +55,15 @@ kotlin { sourceSets { all { languageSettings.apply { - useExperimentalAnnotation("kotlin.ExperimentalStdlibApi") + useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi") useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes") } } commonMain { dependencies { implementation(kotlin("stdlib-common")) - implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializationVersion") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf-common:$serializationVersion") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$serializationVersion") } } commonTest { @@ -74,21 +75,17 @@ kotlin { val jvmMain by getting { dependencies { implementation(kotlin("stdlib-jdk8")) - implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$serializationVersion") } } val jvmTest by getting { dependencies { implementation(kotlin("test")) implementation(kotlin("test-junit")) - implementation("com.hivemq:hivemq-mqtt-client:1.1.3") + implementation("com.hivemq:hivemq-mqtt-client:1.2.1") } } val mingwMain by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-mingwx64:$serializationVersion") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf-mingwx64:$serializationVersion") } } val mingwTest by getting { @@ -97,8 +94,6 @@ kotlin { val linuxX64Main by getting { dependencies { implementation(files("src/nativeInterop/openssl-linux-x64.klib")) - implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-linuxx64:$serializationVersion") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf-linuxx64:$serializationVersion") } } val linuxX64Test by getting { @@ -107,8 +102,6 @@ kotlin { val linuxArm32HfpMain by getting { dependencies { implementation(files("src/nativeInterop/openssl-linux-arm32-hfp.klib")) - implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-linuxarm32hfp:$serializationVersion") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf-linuxarm32hfp:$serializationVersion") } } val linuxArm32HfpTest by getting { diff --git a/gradle.properties b/gradle.properties index ee57dce..5afb744 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ kotlin.code.style=official -serializationVersion=0.20.0 +serializationVersion=1.0.0-RC diff --git a/src/commonMain/kotlin/mqtt/broker/Broker.kt b/src/commonMain/kotlin/mqtt/broker/Broker.kt index 03752a2..c41015f 100644 --- a/src/commonMain/kotlin/mqtt/broker/Broker.kt +++ b/src/commonMain/kotlin/mqtt/broker/Broker.kt @@ -128,7 +128,8 @@ class Broker( matchedSubscriptions.filter { it.value.isShared() }.groupBy { it.value.shareName }.forEach { val shareName = it.key if (shareName != null) { - val subscriptionEntry = it.value.minBy { subscription -> subscription.value.timestampShareSent }!! + val subscriptionEntry = + it.value.minByOrNull { subscription -> subscription.value.timestampShareSent }!! val clientId = subscriptionEntry.key val subscription = subscriptionEntry.value val session = sessions[clientId] diff --git a/src/commonMain/kotlin/mqtt/broker/cluster/ClusterDiscoveryConnection.kt b/src/commonMain/kotlin/mqtt/broker/cluster/ClusterDiscoveryConnection.kt index ef39655..520592c 100644 --- a/src/commonMain/kotlin/mqtt/broker/cluster/ClusterDiscoveryConnection.kt +++ b/src/commonMain/kotlin/mqtt/broker/cluster/ClusterDiscoveryConnection.kt @@ -10,7 +10,7 @@ class ClusterDiscoveryConnection(private val socket: UDPSocket, private val brok override fun dataReceived() { socket.read()?.let { data -> - val packet = ProtoBuf.load(DiscoveryPacket.serializer(), data.data.toByteArray()) + val packet = ProtoBuf.decodeFromByteArray(DiscoveryPacket.serializer(), data.data.toByteArray()) if (packet.name != broker.cluster!!.name) { broker.addClusterConnection(data.sourceAddress) } @@ -18,7 +18,8 @@ class ClusterDiscoveryConnection(private val socket: UDPSocket, private val brok } fun sendDiscovery(port: Int) { - val packet = ProtoBuf.dump(DiscoveryPacket.serializer(), DiscoveryPacket(broker.cluster!!.name)).toUByteArray() + val packet = ProtoBuf.encodeToByteArray(DiscoveryPacket.serializer(), DiscoveryPacket(broker.cluster!!.name)) + .toUByteArray() socket.send(packet, "255.255.255.255", port) } } diff --git a/src/commonMain/kotlin/mqtt/broker/cluster/DiscoveryPacket.kt b/src/commonMain/kotlin/mqtt/broker/cluster/DiscoveryPacket.kt index d768353..d566d84 100644 --- a/src/commonMain/kotlin/mqtt/broker/cluster/DiscoveryPacket.kt +++ b/src/commonMain/kotlin/mqtt/broker/cluster/DiscoveryPacket.kt @@ -1,10 +1,10 @@ package mqtt.broker.cluster import kotlinx.serialization.Serializable -import kotlinx.serialization.protobuf.ProtoId +import kotlinx.serialization.protobuf.ProtoNumber @Serializable data class DiscoveryPacket( - @ProtoId(1) + @ProtoNumber(1) val name: String = "" ) diff --git a/src/linuxArm32HfpMain/kotlin/socket/ServerSocket.kt b/src/linuxArm32HfpMain/kotlin/socket/ServerSocket.kt index 0c3e8df..61a4313 100644 --- a/src/linuxArm32HfpMain/kotlin/socket/ServerSocket.kt +++ b/src/linuxArm32HfpMain/kotlin/socket/ServerSocket.kt @@ -105,7 +105,7 @@ actual open class ServerSocket actual constructor(private val broker: Broker) : clients[discoverySocket] = clusterConnection clusterConnection.sendDiscovery(broker.cluster.discoveryPort) } - maxFd = listOf(mqttSocket, mqttUdpSocket, clusteringSocket, discoverySocket).max()!! + maxFd = listOf(mqttSocket, mqttUdpSocket, clusteringSocket, discoverySocket).maxOrNull()!! } } diff --git a/src/linuxArm32HfpMain/kotlin/socket/tls/openssl.kt b/src/linuxArm32HfpMain/kotlin/socket/tls/openssl.kt index cb41f62..ff2f8b9 100644 --- a/src/linuxArm32HfpMain/kotlin/socket/tls/openssl.kt +++ b/src/linuxArm32HfpMain/kotlin/socket/tls/openssl.kt @@ -153,18 +153,6 @@ import kotlinx.cinterop.* import kotlinx.cinterop.internal.CCall import kotlinx.cinterop.internal.CStruct import platform.posix.* -import kotlin.Any -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.UByte -import kotlin.UInt -import kotlin.ULong -import kotlin.UShort -import kotlin.Unit -import kotlin.UnsupportedOperationException // NOTE THIS FILE IS AUTO-GENERATED @@ -3210,10 +3198,6 @@ external fun BIO_copy_next_retry(b: CValuesRef?): Unit @CCall("knifunptr_openssl364_BIO_printf") external fun BIO_printf(bio: CValuesRef?, @CCall.CString format: String?, vararg variadicArguments: Any?): Int -@Deprecated("Unable to import this declaration", level = DeprecationLevel.ERROR) -fun BIO_vprintf(bio: CValuesRef?, @CCall.CString format: String?, args: CValue): Int = - throw UnsupportedOperationException() - @CCall("knifunptr_openssl366_BIO_snprintf") external fun BIO_snprintf( buf: CValuesRef?, @@ -3222,10 +3206,6 @@ external fun BIO_snprintf( vararg variadicArguments: Any? ): Int -@Deprecated("Unable to import this declaration", level = DeprecationLevel.ERROR) -fun BIO_vsnprintf(buf: CValuesRef?, n: size_t, @CCall.CString format: String?, args: CValue): Int = - throw UnsupportedOperationException() - @CCall("knifunptr_openssl368_BIO_meth_new") external fun BIO_meth_new(type: Int, @CCall.CString name: String?): CPointer? @@ -18881,9 +18861,6 @@ external fun ERR_print_errors(bp: CValuesRef?): Unit @CCall("knifunptr_openssl4086_ERR_add_error_data") external fun ERR_add_error_data(num: Int, vararg variadicArguments: Any?): Unit -@Deprecated("Unable to import this declaration", level = DeprecationLevel.ERROR) -fun ERR_add_error_vdata(num: Int, args: CValue): Unit = throw UnsupportedOperationException() - @CCall("knifunptr_openssl4088_ERR_load_strings") external fun ERR_load_strings(lib: Int, str: CValuesRef?): Int diff --git a/src/linuxX64Main/kotlin/socket/ServerSocket.kt b/src/linuxX64Main/kotlin/socket/ServerSocket.kt index e958740..2858b7c 100644 --- a/src/linuxX64Main/kotlin/socket/ServerSocket.kt +++ b/src/linuxX64Main/kotlin/socket/ServerSocket.kt @@ -105,7 +105,7 @@ actual open class ServerSocket actual constructor(private val broker: Broker) : clients[discoverySocket] = clusterConnection clusterConnection.sendDiscovery(broker.cluster.discoveryPort) } - maxFd = listOf(mqttSocket, mqttUdpSocket, clusteringSocket, discoverySocket).max()!! + maxFd = listOf(mqttSocket, mqttUdpSocket, clusteringSocket, discoverySocket).maxOrNull()!! } } diff --git a/src/linuxX64Main/resources/Dockerfile b/src/linuxX64Main/resources/Dockerfile index 48112e3..3f43cff 100644 --- a/src/linuxX64Main/resources/Dockerfile +++ b/src/linuxX64Main/resources/Dockerfile @@ -29,12 +29,12 @@ RUN set -x \ ENV OPENSSL_VERSION="1.1.1g" RUN set -x \ - && wget --no-check-certificate -O /tmp/kotlin-native-linux-1.3.72.tar.gz "https://github.com/JetBrains/kotlin/releases/download/v1.3.72/kotlin-native-linux-1.3.72.tar.gz" \ + && wget --no-check-certificate -O /tmp/kotlin-native-linux-1.4.tar.gz "https://github.com/JetBrains/kotlin/releases/download/v1.4.0/kotlin-native-linux-1.4.tar.gz" \ && cd /tmp \ - && tar -xzvf kotlin-native-linux-1.3.72.tar.gz + && tar -xzvf kotlin-native-linux-1.4.tar.gz RUN set -x \ - && /tmp/kotlin-native-linux-1.3.72/bin/cinterop -def openssl.def; exit 0 + && /tmp/kotlin-native-linux-1.4/bin/cinterop -def openssl.def; exit 0 RUN set -x \ ### BUILD OpenSSL @@ -68,16 +68,16 @@ RUN set -x \ && cd /tmp \ && mkdir klib_linux_x64 \ && cd /tmp/klib_linux_x64 \ - && ../kotlin-native-linux-1.3.72/bin/cinterop -def ../openssl.def -target "linux_x64" -o openssl + && ../kotlin-native-linux-1.4/bin/cinterop -def ../openssl.def -target "linux_x64" -o openssl #RUN set -x \ # && cd /tmp \ # && mkdir klib_mingw_x64 \ # && cd /tmp/klib_mingw_x64 \ -# && ../kotlin-native-linux-1.3.72/bin/cinterop -def ../openssl.def -target "mingw_x64" -o openssl +# && ../kotlin-native-linux-1.4/bin/cinterop -def ../openssl.def -target "mingw_x64" -o openssl RUN set -x \ && cd /tmp \ && mkdir klib_linux_arm32_hfp \ && cd /tmp/klib_linux_arm32_hfp \ - && ../kotlin-native-linux-1.3.72/bin/cinterop -def ../openssl.def -target "linux_arm32_hfp" -o openssl + && ../kotlin-native-linux-1.4/bin/cinterop -def ../openssl.def -target "linux_arm32_hfp" -o openssl diff --git a/src/nativeInterop/cinterop/opensslLibs/mingwX64/libcrypto.a b/src/nativeInterop/cinterop/opensslLibs/mingwX64/libcrypto.a index d203c81..f67f801 100644 Binary files a/src/nativeInterop/cinterop/opensslLibs/mingwX64/libcrypto.a and b/src/nativeInterop/cinterop/opensslLibs/mingwX64/libcrypto.a differ diff --git a/src/nativeInterop/openssl-linux-arm32-hfp.klib b/src/nativeInterop/openssl-linux-arm32-hfp.klib index f4b0982..653f99b 100644 Binary files a/src/nativeInterop/openssl-linux-arm32-hfp.klib and b/src/nativeInterop/openssl-linux-arm32-hfp.klib differ diff --git a/src/nativeInterop/openssl-linux-x64.klib b/src/nativeInterop/openssl-linux-x64.klib index 9fbb8cc..ef661e0 100644 Binary files a/src/nativeInterop/openssl-linux-x64.klib and b/src/nativeInterop/openssl-linux-x64.klib differ