mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
remove message chain
This commit is contained in:
parent
f3cab51927
commit
4115f7d16e
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -16,7 +16,7 @@ package de.bixilon.minosoft.commands.stack
|
||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||
import de.bixilon.minosoft.commands.stack.print.PrintTarget
|
||||
import de.bixilon.minosoft.commands.stack.print.SystemPrintTarget
|
||||
import de.bixilon.minosoft.data.chat.signature.MessageChain
|
||||
import de.bixilon.minosoft.data.chat.signature.signer.MessageSigner
|
||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import java.security.PrivateKey
|
||||
@ -55,7 +55,7 @@ class CommandStack(
|
||||
stack.add(CommandStackEntry(name, data))
|
||||
}
|
||||
|
||||
fun sign(chain: MessageChain, key: PrivateKey, salt: Long, time: Instant): Map<String, ByteArray> {
|
||||
fun sign(chain: MessageSigner, key: PrivateKey, salt: Long, time: Instant): Map<String, ByteArray> {
|
||||
val output: MutableMap<String, ByteArray> = mutableMapOf()
|
||||
for (entry in stack) {
|
||||
output[entry.name] = entry.sign(connection, chain, key, salt, time)
|
||||
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.data.chat.signature
|
||||
|
||||
import de.bixilon.minosoft.data.chat.signature.signer.MessageSigner
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.versions.Version
|
||||
import java.security.PrivateKey
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
|
||||
class MessageChain(version: Version, connection: PlayConnection) {
|
||||
val signer = MessageSigner.forVersion(version, connection)
|
||||
|
||||
fun signMessage(privateKey: PrivateKey, message: String, preview: ChatComponent?, salt: Long, sender: UUID, time: Instant, lastSeen: LastSeenMessageList): ByteArray {
|
||||
return signer.signMessage(privateKey, message, preview, salt, sender, time, lastSeen)
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ import de.bixilon.minosoft.commands.stack.CommandStack
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.chat.message.InternalChatMessage
|
||||
import de.bixilon.minosoft.data.chat.signature.Acknowledgement
|
||||
import de.bixilon.minosoft.data.chat.signature.MessageChain
|
||||
import de.bixilon.minosoft.data.chat.signature.signer.MessageSigner
|
||||
import de.bixilon.minosoft.data.entities.entities.player.local.HealthCondition
|
||||
import de.bixilon.minosoft.data.text.BaseComponent
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
@ -47,7 +47,7 @@ import java.time.Instant
|
||||
class ConnectionUtil(
|
||||
private val connection: PlayConnection,
|
||||
) {
|
||||
private val chain = MessageChain(connection.version, connection)
|
||||
val signer = MessageSigner.forVersion(connection.version, connection)
|
||||
private val random = SecureRandom()
|
||||
|
||||
fun sendDebugMessage(message: Any) {
|
||||
@ -97,7 +97,7 @@ class ConnectionUtil(
|
||||
val acknowledgement = Acknowledgement.EMPTY
|
||||
|
||||
val signature: ByteArray? = if (connection.network.encrypted) {
|
||||
chain.signMessage(privateKey, message, null, salt, uuid, time, acknowledgement.lastSeen)
|
||||
signer.signMessage(privateKey, message, null, salt, uuid, time, acknowledgement.lastSeen)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
@ -117,7 +117,7 @@ class ConnectionUtil(
|
||||
|
||||
val key = connection.player.privateKey
|
||||
if (key != null && connection.network.encrypted && connection.profiles.connection.signature.signCommands) {
|
||||
signature = stack.sign(chain, key.private, salt, time)
|
||||
signature = stack.sign(signer, key.private, salt, time)
|
||||
}
|
||||
|
||||
connection.sendPacket(CommandC2SP(command.trimWhitespaces().removePrefix("/"), time, salt, signature, false, acknowledgement))
|
||||
|
Loading…
x
Reference in New Issue
Block a user