Skip to content

Commit

Permalink
update netty, ktor and kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
creeper123123321 committed Nov 23, 2024
1 parent 2d58442 commit 1b89ab9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
9 changes: 5 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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<String> by extra

Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
7 changes: 5 additions & 2 deletions src/main/kotlin/com/viaversion/aas/AspirinServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.DurationUnit

object AspirinServer {
var ktorServer: NettyApplicationEngine? = null
var ktorServer: EmbeddedServer<NettyApplicationEngine, NettyApplicationEngine.Configuration>? = null
val version = JsonParser.parseString(
AspirinPlatform::class.java.classLoader
.getResourceAsStream("viaaas_info.json")!!
Expand Down Expand Up @@ -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: {}",
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/com/viaversion/aas/web/ViaWebApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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() {
Expand All @@ -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)
Expand Down

0 comments on commit 1b89ab9

Please sign in to comment.