diff --git a/build.gradle.kts b/build.gradle.kts index 7ec460f..9c9b8e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { - kotlin("jvm") version "2.0.0" + kotlin("jvm") version "2.0.10" application id("io.ktor.plugin") version "2.3.12" } @@ -20,8 +20,8 @@ implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.17.2") implementation("com.github.pemistahl:lingua:1.2.2") - implementation("com.google.protobuf:protobuf-java:4.27.2") - implementation("com.google.protobuf:protobuf-kotlin:4.27.2") + implementation("com.google.protobuf:protobuf-java:4.27.3") + implementation("com.google.protobuf:protobuf-kotlin:4.27.3") implementation("com.ibm.icu:icu4j:75.1") implementation("com.lmax:disruptor:4.0.0") implementation("com.sun.mail:jakarta.mail:2.0.1") @@ -29,7 +29,7 @@ implementation("commons-io:commons-io:2.16.1") implementation("io.netty:netty-all:4.1.112.Final") implementation("jakarta.mail:jakarta.mail-api:2.1.3") - implementation("net.dv8tion:JDA:5.0.1") + implementation("net.dv8tion:JDA:5.0.2") implementation("org.apache.commons:commons-compress:1.26.2") implementation("org.apache.commons:commons-dbcp2:2.12.0") implementation("org.apache.commons:commons-lang3:3.15.0") @@ -43,7 +43,7 @@ implementation("org.python:jython-standalone:2.7.3") implementation("org.seleniumhq.selenium:selenium-edge-driver:4.23.0") implementation("org.seleniumhq.selenium:selenium-java:4.23.0") - implementation("org.tukaani:xz:1.9") + implementation("org.tukaani:xz:1.10") implementation(kotlin("stdlib-jdk8")) testImplementation(kotlin("test")) } diff --git a/src/main/kotlin/net/taehui/twilight/Twilight.kt b/src/main/kotlin/net/taehui/twilight/Twilight.kt index 9d23691..db0278b 100644 --- a/src/main/kotlin/net/taehui/twilight/Twilight.kt +++ b/src/main/kotlin/net/taehui/twilight/Twilight.kt @@ -1,7 +1,5 @@ package net.taehui.twilight -import io.netty.channel.epoll.EpollEventLoopGroup -import io.netty.channel.epoll.EpollServerSocketChannel import io.netty.channel.nio.NioEventLoopGroup import io.netty.channel.socket.ServerSocketChannel import io.netty.channel.socket.nio.NioServerSocketChannel @@ -53,10 +51,7 @@ exitProcess(1) } - (if (SystemUtils.IS_OS_LINUX) EpollEventLoopGroup() else NioEventLoopGroup()).use { eventLoopGroup -> - val eventChannel: Class = - if (SystemUtils.IS_OS_LINUX) EpollServerSocketChannel::class.java else NioServerSocketChannel::class.java - + NioEventLoopGroup().use { eventLoopGroup -> Configure.loadConfigure() DB.loadDB() @@ -94,10 +89,10 @@ sslContext } - QwilightBoot(eventLoopGroup, eventChannel, sslContext).use { - SiteBoot(eventLoopGroup, eventChannel).use { - WwwBoot(eventLoopGroup, eventChannel).use { - TaehuiBoot(eventLoopGroup, eventChannel).use { + QwilightBoot(eventLoopGroup, sslContext).use { + SiteBoot(eventLoopGroup).use { + WwwBoot(eventLoopGroup).use { + TaehuiBoot(eventLoopGroup).use { AvatarHandler.sendClose(IO.handleSystem()) } } diff --git a/src/main/kotlin/net/taehui/twilight/qwilight/QwilightBoot.kt b/src/main/kotlin/net/taehui/twilight/qwilight/QwilightBoot.kt index b192970..308354f 100644 --- a/src/main/kotlin/net/taehui/twilight/qwilight/QwilightBoot.kt +++ b/src/main/kotlin/net/taehui/twilight/qwilight/QwilightBoot.kt @@ -6,6 +6,7 @@ import io.netty.channel.EventLoopGroup import io.netty.channel.socket.ServerSocketChannel import io.netty.channel.socket.SocketChannel +import io.netty.channel.socket.nio.NioServerSocketChannel import io.netty.handler.codec.protobuf.ProtobufDecoder import io.netty.handler.codec.protobuf.ProtobufEncoder import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder @@ -14,27 +15,26 @@ import net.taehui.twilight.Logger import javax.net.ssl.SSLContext -class QwilightBoot( - eventLoopGroup: EventLoopGroup, eventChannel: Class, sslContext: SSLContext -) : Logger, AutoCloseable { - private val mainBootstrap: ServerBootstrap = ServerBootstrap().group(eventLoopGroup).channel(eventChannel) - .childHandler(object : ChannelInitializer() { - public override fun initChannel(ch: SocketChannel) { - ch.pipeline().addLast(SslHandler(sslContext.createSSLEngine().apply { +class QwilightBoot(eventLoopGroup: EventLoopGroup, sslContext: SSLContext) : Logger, AutoCloseable { + private val mainBootstrap: ServerBootstrap = + ServerBootstrap().group(eventLoopGroup).channel(NioServerSocketChannel::class.java) + .childHandler(object : ChannelInitializer() { + public override fun initChannel(ch: SocketChannel) { + ch.pipeline().addLast(SslHandler(sslContext.createSSLEngine().apply { useClientMode = false })).addLast(ProtobufVarint32FrameDecoder()) - .addLast(ProtobufDecoder(EventOuterClass.Event.getDefaultInstance())) - .addLast(ProtobufVarint32LengthFieldPrepender()).addLast(ProtobufEncoder()) - .addLast(QwilightAvatar()) - } - }) + .addLast(ProtobufDecoder(EventOuterClass.Event.getDefaultInstance())) + .addLast(ProtobufVarint32LengthFieldPrepender()).addLast(ProtobufEncoder()) + .addLast(QwilightAvatar()) + } + }) private val mainChannel: Channel init { logInfo("Loading Qwilight") mainChannel = mainBootstrap.bind(6101).channel().closeFuture().addListener { - logInfo("Closed Qwilight") - }.channel() + logInfo("Closed Qwilight") + }.channel() } override fun close() { diff --git a/src/main/kotlin/net/taehui/twilight/site/SiteBoot.kt b/src/main/kotlin/net/taehui/twilight/site/SiteBoot.kt index 8268e63..0e91ebb 100644 --- a/src/main/kotlin/net/taehui/twilight/site/SiteBoot.kt +++ b/src/main/kotlin/net/taehui/twilight/site/SiteBoot.kt @@ -6,14 +6,15 @@ import io.netty.channel.EventLoopGroup import io.netty.channel.socket.ServerSocketChannel import io.netty.channel.socket.SocketChannel +import io.netty.channel.socket.nio.NioServerSocketChannel import io.netty.handler.codec.http.HttpObjectAggregator import io.netty.handler.codec.http.HttpServerCodec import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler import io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketServerCompressionHandler import net.taehui.twilight.Logger -class SiteBoot(eventLoopGroup: EventLoopGroup, eventChannel: Class) : Logger, AutoCloseable { - private val mainBootstrap: ServerBootstrap = ServerBootstrap().group(eventLoopGroup).channel(eventChannel) +class SiteBoot(eventLoopGroup: EventLoopGroup) : Logger, AutoCloseable { + private val mainBootstrap: ServerBootstrap = ServerBootstrap().group(eventLoopGroup).channel(NioServerSocketChannel::class.java) .childHandler(object : ChannelInitializer() { public override fun initChannel(ch: SocketChannel) { ch.pipeline() diff --git a/src/main/kotlin/net/taehui/twilight/system/DB.kt b/src/main/kotlin/net/taehui/twilight/system/DB.kt index eb6ecad..30be95c 100644 --- a/src/main/kotlin/net/taehui/twilight/system/DB.kt +++ b/src/main/kotlin/net/taehui/twilight/system/DB.kt @@ -1849,7 +1849,6 @@ VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, 0) """.trimIndent() ).use { dbStatement -> - val isSalt = targetComputing.isSalt dbStatement.setString(1, noteID) dbStatement.setString(2, noteID128) dbStatement.setString(3, noteID256) @@ -1861,10 +1860,10 @@ dbStatement.setInt(9, targetComputing.level) dbStatement.setInt(10, targetComputing.inputMode.value) dbStatement.setInt(11, targetComputing.totalNotes) - dbStatement.setBoolean(12, isSalt) + dbStatement.setBoolean(12, targetComputing.isSalt) dbStatement.setDouble( 13, - if (isSalt) 0.0 else AbilitySystem.getAbility( + AbilitySystem.getAbility( AbilityClassSystem.AbilityClassVariety.INPUT_MODE_6K, noteID128, noteID256 @@ -1872,7 +1871,7 @@ ) dbStatement.setDouble( 14, - if (isSalt) 0.0 else AbilitySystem.getAbility( + AbilitySystem.getAbility( AbilityClassSystem.AbilityClassVariety.INPUT_MODE_5K, noteID128, noteID256 @@ -1880,7 +1879,7 @@ ) dbStatement.setDouble( 15, - if (isSalt) 0.0 else AbilitySystem.getAbility( + AbilitySystem.getAbility( AbilityClassSystem.AbilityClassVariety.INPUT_MODE_7K, noteID128, noteID256 @@ -1888,7 +1887,7 @@ ) dbStatement.setDouble( 16, - if (isSalt) 0.0 else AbilitySystem.getAbility( + AbilitySystem.getAbility( AbilityClassSystem.AbilityClassVariety.INPUT_MODE_9K, noteID128, noteID256 @@ -1936,7 +1935,7 @@ } fun learnAbility() { - data class NoteID(val noteID: String, val noteID128: String, val noteID256: String, val isSalt: Boolean) + data class NoteID(val noteID: String, val noteID128: String, val noteID256: String) val noteIDs = mutableListOf() pool.connection.use { @@ -1952,8 +1951,7 @@ NoteID( rows.getString("Note_ID"), rows.getString("Note_ID_128"), - rows.getString("Note_ID_256"), - rows.getBoolean("Is_Salt") + rows.getString("Note_ID_256") ) ) } @@ -1962,7 +1960,7 @@ } noteIDs.parallelStream().use { parallel -> - parallel.forEach { (noteID, noteID128, noteID256, isSalt) -> + parallel.forEach { (noteID, noteID128, noteID256) -> pool.connection.use { it.prepareStatement( """ @@ -1973,7 +1971,7 @@ ).use { dbStatement -> dbStatement.setDouble( 1, - if (isSalt) 0.0 else AbilitySystem.getAbility( + AbilitySystem.getAbility( AbilityClassSystem.AbilityClassVariety.INPUT_MODE_6K, noteID128, noteID256 @@ -1981,7 +1979,7 @@ ) dbStatement.setDouble( 2, - if (isSalt) 0.0 else AbilitySystem.getAbility( + AbilitySystem.getAbility( AbilityClassSystem.AbilityClassVariety.INPUT_MODE_5K, noteID128, noteID256 @@ -1989,7 +1987,7 @@ ) dbStatement.setDouble( 3, - if (isSalt) 0.0 else AbilitySystem.getAbility( + AbilitySystem.getAbility( AbilityClassSystem.AbilityClassVariety.INPUT_MODE_7K, noteID128, noteID256 @@ -1997,7 +1995,7 @@ ) dbStatement.setDouble( 4, - if (isSalt) 0.0 else AbilitySystem.getAbility( + AbilitySystem.getAbility( AbilityClassSystem.AbilityClassVariety.INPUT_MODE_9K, noteID128, noteID256 diff --git a/src/main/kotlin/net/taehui/twilight/taehui/TaehuiAvatar.kt b/src/main/kotlin/net/taehui/twilight/taehui/TaehuiAvatar.kt index 45e1954..f6c53fd 100644 --- a/src/main/kotlin/net/taehui/twilight/taehui/TaehuiAvatar.kt +++ b/src/main/kotlin/net/taehui/twilight/taehui/TaehuiAvatar.kt @@ -95,8 +95,8 @@ val hashARM64 = data[2] if (date.contains("!")) { Configure.hash.clear() + date = date.replace("!", "") } - date = date.replace("!", "") Configure.hash.add(hashAMD64) Configure.hash.add(hashARM64) val jm = ObjectMapper() diff --git a/src/main/kotlin/net/taehui/twilight/taehui/TaehuiBoot.kt b/src/main/kotlin/net/taehui/twilight/taehui/TaehuiBoot.kt index c71bd60..81ced6d 100644 --- a/src/main/kotlin/net/taehui/twilight/taehui/TaehuiBoot.kt +++ b/src/main/kotlin/net/taehui/twilight/taehui/TaehuiBoot.kt @@ -6,13 +6,14 @@ import io.netty.channel.EventLoopGroup import io.netty.channel.socket.ServerSocketChannel import io.netty.channel.socket.SocketChannel +import io.netty.channel.socket.nio.NioServerSocketChannel import io.netty.handler.codec.http.HttpClientCodec import io.netty.handler.codec.http.HttpObjectAggregator import io.netty.handler.codec.http.HttpServerCodec import net.taehui.twilight.Logger -class TaehuiBoot(eventLoopGroup: EventLoopGroup, eventChannel: Class) : Logger, AutoCloseable { - private val mainBootstrap: ServerBootstrap = ServerBootstrap().group(eventLoopGroup).channel(eventChannel) +class TaehuiBoot(eventLoopGroup: EventLoopGroup) : Logger, AutoCloseable { + private val mainBootstrap: ServerBootstrap = ServerBootstrap().group(eventLoopGroup).channel(NioServerSocketChannel::class.java) .childHandler(object : ChannelInitializer() { public override fun initChannel(ch: SocketChannel) { ch.pipeline() diff --git a/src/main/kotlin/net/taehui/twilight/www/WwwBoot.kt b/src/main/kotlin/net/taehui/twilight/www/WwwBoot.kt index 065ec34..94ed5f1 100644 --- a/src/main/kotlin/net/taehui/twilight/www/WwwBoot.kt +++ b/src/main/kotlin/net/taehui/twilight/www/WwwBoot.kt @@ -6,13 +6,14 @@ import io.netty.channel.EventLoopGroup import io.netty.channel.socket.ServerSocketChannel import io.netty.channel.socket.SocketChannel +import io.netty.channel.socket.nio.NioServerSocketChannel import io.netty.handler.codec.http.HttpClientCodec import io.netty.handler.codec.http.HttpObjectAggregator import io.netty.handler.codec.http.HttpServerCodec import net.taehui.twilight.Logger -class WwwBoot(eventLoopGroup: EventLoopGroup, eventChannel: Class) : Logger, AutoCloseable { - private val mainBootstrap: ServerBootstrap = ServerBootstrap().group(eventLoopGroup).channel(eventChannel) +class WwwBoot(eventLoopGroup: EventLoopGroup) : Logger, AutoCloseable { + private val mainBootstrap: ServerBootstrap = ServerBootstrap().group(eventLoopGroup).channel(NioServerSocketChannel::class.java) .childHandler(object : ChannelInitializer() { public override fun initChannel(ch: SocketChannel) { ch.pipeline().addLast(HttpServerCodec()).addLast(HttpObjectAggregator(Int.MAX_VALUE))