diff --git a/src/main/java/de/bixilon/minosoft/config/profile/profiles/connection/ConnectionProfile.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/connection/ConnectionProfile.kt index 1caa78064..db7ccaa09 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/profiles/connection/ConnectionProfile.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/connection/ConnectionProfile.kt @@ -18,6 +18,7 @@ import de.bixilon.minosoft.config.profile.ProfileManager import de.bixilon.minosoft.config.profile.profiles.Profile import de.bixilon.minosoft.config.profile.profiles.connection.ConnectionProfileManager.delegate import de.bixilon.minosoft.config.profile.profiles.connection.ConnectionProfileManager.latestVersion +import de.bixilon.minosoft.config.profile.profiles.connection.signature.SignatureC import de.bixilon.minosoft.config.profile.profiles.connection.skin.SkinC import de.bixilon.minosoft.data.entities.entities.player.Arms @@ -55,6 +56,7 @@ class ConnectionProfile( var mainArm by delegate(Arms.RIGHT) val skin = SkinC() + val signature = SignatureC() var autoRespawn by delegate(false) diff --git a/src/main/java/de/bixilon/minosoft/config/profile/profiles/connection/signature/SignatureC.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/connection/signature/SignatureC.kt new file mode 100644 index 000000000..3a26104a2 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/connection/signature/SignatureC.kt @@ -0,0 +1,34 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 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 . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.config.profile.profiles.connection.signature + +import de.bixilon.minosoft.config.profile.profiles.connection.ConnectionProfileManager.delegate + +class SignatureC { + + /** + * Hides all bad signed messages + */ + val ignoreBadSignedMessages by delegate(false) + + /** + * Does not fetch/load the private key, thus forcing the unsigned mode + */ + val disableKeys by delegate(false) + + /** + * Send commands as message + */ + val sendCommandAsMessage by delegate(false) +} diff --git a/src/main/java/de/bixilon/minosoft/protocol/network/connection/play/ConnectionUtil.kt b/src/main/java/de/bixilon/minosoft/protocol/network/connection/play/ConnectionUtil.kt index a32569c44..538e7657c 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/network/connection/play/ConnectionUtil.kt +++ b/src/main/java/de/bixilon/minosoft/protocol/network/connection/play/ConnectionUtil.kt @@ -94,7 +94,7 @@ class ConnectionUtil( @Deprecated("message will re removed as soon as brigadier is fully implemented") fun sendCommand(message: String, stack: CommandStack) { - if (!connection.version.requiresSignedChat) { + if (!connection.version.requiresSignedChat || connection.profiles.connection.signature.sendCommandAsMessage) { return sendChatMessage(message) } TODO("Can not send signed chat!") diff --git a/src/main/java/de/bixilon/minosoft/protocol/network/connection/play/PlayConnection.kt b/src/main/java/de/bixilon/minosoft/protocol/network/connection/play/PlayConnection.kt index 944f0d7a3..30a8afd6a 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/network/connection/play/PlayConnection.kt +++ b/src/main/java/de/bixilon/minosoft/protocol/network/connection/play/PlayConnection.kt @@ -185,7 +185,7 @@ class PlayConnection( Log.log(LogMessageType.ASSETS, LogLevels.INFO) { "Assets verified!" } } var privateKey: PlayerPrivateKey? = null - if (version.requiresSignedChat) { + if (version.requiresSignedChat && !profiles.connection.signature.disableKeys) { taskWorker += WorkerTask(optional = true) { val minecraftKey = account.fetchKey(latch) ?: return@WorkerTask minecraftKey.requireSignature(account.uuid) diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/chat/SignedChatMessageS2CP.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/chat/SignedChatMessageS2CP.kt index 365f73911..a57b4aeca 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/chat/SignedChatMessageS2CP.kt +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/chat/SignedChatMessageS2CP.kt @@ -110,6 +110,14 @@ class SignedChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket { } override fun handle(connection: PlayConnection) { + if (message.error != null) { + // failed + Log.log(LogMessageType.CHAT_IN, LogLevels.WARN) { "Signature error: ${message.error}: ${message.text}" } + + if (connection.profiles.connection.signature.ignoreBadSignedMessages) { + return + } + } connection.fireEvent(ChatMessageReceiveEvent(connection, EventInitiators.SERVER, message)) }