From 1b89ab9308eb03313d99fc6a8c0cbe7ebe1d2a91 Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Sat, 23 Nov 2024 15:17:04 -0300 Subject: [PATCH] update netty, ktor and kotlin --- build.gradle.kts | 9 +++++---- src/main/kotlin/com/viaversion/aas/AspirinServer.kt | 7 +++++-- src/main/kotlin/com/viaversion/aas/web/ViaWebApp.kt | 8 ++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ecdbb62..55a7be8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,6 +4,7 @@ import com.google.javascript.jscomp.CompilerOptions.LanguageMode import com.googlecode.htmlcompressor.compressor.HtmlCompressor import org.gradlewebtools.minify.minifier.js.JsMinifier import org.gradlewebtools.minify.minifier.js.JsMinifierOptions +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.nio.file.Files as JFiles @@ -15,7 +16,7 @@ buildscript { plugins { `java-library` application - kotlin("jvm") version "1.9.22" + kotlin("jvm") version "2.0.21" id("maven-publish") id("com.github.ben-manes.versions") version "0.50.0" id("com.github.johnrengelman.shadow") version "8.1.1" @@ -36,7 +37,7 @@ java { } val compileKotlin: KotlinCompile by tasks -compileKotlin.kotlinOptions.jvmTarget = "17" +compileKotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_17) val gitVersion: groovy.lang.Closure by extra @@ -70,7 +71,7 @@ dependencies { implementation("net.raphimc:viaaprilfools-common:$vafVer") { isTransitive = false } implementation("net.raphimc:ViaLegacy:3.0.6-SNAPSHOT") - val nettyVer = "4.1.111.Final" + val nettyVer = "4.1.115.Final" implementation("io.netty:netty-handler-proxy:$nettyVer") implementation("io.netty:netty-resolver-dns:$nettyVer") implementation("io.netty:netty-transport-native-epoll:$nettyVer:linux-aarch_64") @@ -97,7 +98,7 @@ dependencies { implementation("org.jline:jline-terminal-jansi:3.25.1") implementation("org.slf4j:slf4j-api:$slf4jVer") - val ktorVersion = "2.3.12" + val ktorVersion = "3.0.1" implementation("io.ktor:ktor-network-tls-certificates-jvm:$ktorVersion") implementation("io.ktor:ktor-server-websockets:$ktorVersion") implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion") diff --git a/src/main/kotlin/com/viaversion/aas/AspirinServer.kt b/src/main/kotlin/com/viaversion/aas/AspirinServer.kt index cf4e6a8..664328c 100644 --- a/src/main/kotlin/com/viaversion/aas/AspirinServer.kt +++ b/src/main/kotlin/com/viaversion/aas/AspirinServer.kt @@ -37,7 +37,7 @@ import kotlin.time.Duration.Companion.milliseconds import kotlin.time.DurationUnit object AspirinServer { - var ktorServer: NettyApplicationEngine? = null + var ktorServer: EmbeddedServer? = null val version = JsonParser.parseString( AspirinPlatform::class.java.classLoader .getResourceAsStream("viaaas_info.json")!! @@ -125,7 +125,10 @@ object AspirinServer { chFutures.add(serverBootstrap.bind(it.host, it.port)) } - ktorServer = embeddedServer(Netty, commandLineEnvironment(args)) {}.start(false) + val commandLineCfg = CommandLineConfig(args) + ktorServer = embeddedServer(factory = Netty, rootConfig = commandLineCfg.rootConfig) { + takeFrom(commandLineCfg.engineConfig) + }.start(false) viaaasLogger.info( "Using compression: {}, crypto: {}", diff --git a/src/main/kotlin/com/viaversion/aas/web/ViaWebApp.kt b/src/main/kotlin/com/viaversion/aas/web/ViaWebApp.kt index 43d2009..79a7b73 100644 --- a/src/main/kotlin/com/viaversion/aas/web/ViaWebApp.kt +++ b/src/main/kotlin/com/viaversion/aas/web/ViaWebApp.kt @@ -7,7 +7,7 @@ import io.ktor.server.application.* import io.ktor.server.http.content.* import io.ktor.server.plugins.* import io.ktor.server.plugins.cachingheaders.* -import io.ktor.server.plugins.callloging.* +import io.ktor.server.plugins.calllogging.* import io.ktor.server.plugins.compression.* import io.ktor.server.plugins.conditionalheaders.* import io.ktor.server.plugins.contentnegotiation.* @@ -24,7 +24,7 @@ import kotlinx.coroutines.channels.consumeEach import org.slf4j.event.Level import java.io.File import java.nio.file.Path -import java.time.Duration +import kotlin.time.Duration.Companion.seconds class ViaWebApp(val viaWebServer: WebServer) { fun Application.main() { @@ -40,8 +40,8 @@ class ViaWebApp(val viaWebServer: WebServer) { } install(WebSockets) { maxFrameSize = Short.MAX_VALUE.toLong() - pingPeriod = Duration.ofSeconds(20) - timeout = Duration.ofSeconds(15) + pingPeriod = 20.seconds + timeout = 15.seconds contentConverter = GsonWebsocketContentConverter() } install(XForwardedHeaders)