update netty, ktor and kotlin

This commit is contained in:
creeper123123321 2024-11-23 15:17:04 -03:00
parent 2d58442b5d
commit 1b89ab9308
3 changed files with 14 additions and 10 deletions

View File

@ -4,6 +4,7 @@ import com.google.javascript.jscomp.CompilerOptions.LanguageMode
import com.googlecode.htmlcompressor.compressor.HtmlCompressor import com.googlecode.htmlcompressor.compressor.HtmlCompressor
import org.gradlewebtools.minify.minifier.js.JsMinifier import org.gradlewebtools.minify.minifier.js.JsMinifier
import org.gradlewebtools.minify.minifier.js.JsMinifierOptions import org.gradlewebtools.minify.minifier.js.JsMinifierOptions
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.nio.file.Files as JFiles import java.nio.file.Files as JFiles
@ -15,7 +16,7 @@ buildscript {
plugins { plugins {
`java-library` `java-library`
application application
kotlin("jvm") version "1.9.22" kotlin("jvm") version "2.0.21"
id("maven-publish") id("maven-publish")
id("com.github.ben-manes.versions") version "0.50.0" id("com.github.ben-manes.versions") version "0.50.0"
id("com.github.johnrengelman.shadow") version "8.1.1" id("com.github.johnrengelman.shadow") version "8.1.1"
@ -36,7 +37,7 @@ java {
} }
val compileKotlin: KotlinCompile by tasks val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions.jvmTarget = "17" compileKotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
val gitVersion: groovy.lang.Closure<String> by extra val gitVersion: groovy.lang.Closure<String> by extra
@ -70,7 +71,7 @@ dependencies {
implementation("net.raphimc:viaaprilfools-common:$vafVer") { isTransitive = false } implementation("net.raphimc:viaaprilfools-common:$vafVer") { isTransitive = false }
implementation("net.raphimc:ViaLegacy:3.0.6-SNAPSHOT") 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-handler-proxy:$nettyVer")
implementation("io.netty:netty-resolver-dns:$nettyVer") implementation("io.netty:netty-resolver-dns:$nettyVer")
implementation("io.netty:netty-transport-native-epoll:$nettyVer:linux-aarch_64") 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.jline:jline-terminal-jansi:3.25.1")
implementation("org.slf4j:slf4j-api:$slf4jVer") 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-network-tls-certificates-jvm:$ktorVersion")
implementation("io.ktor:ktor-server-websockets:$ktorVersion") implementation("io.ktor:ktor-server-websockets:$ktorVersion")
implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion") implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion")

View File

@ -37,7 +37,7 @@ import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.DurationUnit import kotlin.time.DurationUnit
object AspirinServer { object AspirinServer {
var ktorServer: NettyApplicationEngine? = null var ktorServer: EmbeddedServer<NettyApplicationEngine, NettyApplicationEngine.Configuration>? = null
val version = JsonParser.parseString( val version = JsonParser.parseString(
AspirinPlatform::class.java.classLoader AspirinPlatform::class.java.classLoader
.getResourceAsStream("viaaas_info.json")!! .getResourceAsStream("viaaas_info.json")!!
@ -125,7 +125,10 @@ object AspirinServer {
chFutures.add(serverBootstrap.bind(it.host, it.port)) 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( viaaasLogger.info(
"Using compression: {}, crypto: {}", "Using compression: {}, crypto: {}",

View File

@ -7,7 +7,7 @@ import io.ktor.server.application.*
import io.ktor.server.http.content.* import io.ktor.server.http.content.*
import io.ktor.server.plugins.* import io.ktor.server.plugins.*
import io.ktor.server.plugins.cachingheaders.* 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.compression.*
import io.ktor.server.plugins.conditionalheaders.* import io.ktor.server.plugins.conditionalheaders.*
import io.ktor.server.plugins.contentnegotiation.* import io.ktor.server.plugins.contentnegotiation.*
@ -24,7 +24,7 @@ import kotlinx.coroutines.channels.consumeEach
import org.slf4j.event.Level import org.slf4j.event.Level
import java.io.File import java.io.File
import java.nio.file.Path import java.nio.file.Path
import java.time.Duration import kotlin.time.Duration.Companion.seconds
class ViaWebApp(val viaWebServer: WebServer) { class ViaWebApp(val viaWebServer: WebServer) {
fun Application.main() { fun Application.main() {
@ -40,8 +40,8 @@ class ViaWebApp(val viaWebServer: WebServer) {
} }
install(WebSockets) { install(WebSockets) {
maxFrameSize = Short.MAX_VALUE.toLong() maxFrameSize = Short.MAX_VALUE.toLong()
pingPeriod = Duration.ofSeconds(20) pingPeriod = 20.seconds
timeout = Duration.ofSeconds(15) timeout = 15.seconds
contentConverter = GsonWebsocketContentConverter() contentConverter = GsonWebsocketContentConverter()
} }
install(XForwardedHeaders) install(XForwardedHeaders)