mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
add packet debug toggle
This commit is contained in:
parent
e744ff206b
commit
98d4781d2c
8 changed files with 66 additions and 13 deletions
|
|
@ -90,6 +90,17 @@ namespace MinecraftClient.Logger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void PacketDebug(string msg)
|
||||||
|
{
|
||||||
|
if (Settings.Config.Logging.PacketDebugMessages)
|
||||||
|
{
|
||||||
|
if (ShouldDisplay(FilterChannel.Debug, msg))
|
||||||
|
{
|
||||||
|
LogAndSave("§8[DEBUG] " + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Error(string msg)
|
public override void Error(string msg)
|
||||||
{
|
{
|
||||||
base.Error(msg);
|
base.Error(msg);
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,17 @@ namespace MinecraftClient.Logger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void PacketDebug(string msg)
|
||||||
|
{
|
||||||
|
if (Settings.Config.Logging.PacketDebugMessages)
|
||||||
|
{
|
||||||
|
if (ShouldDisplay(FilterChannel.Debug, msg))
|
||||||
|
{
|
||||||
|
Log("§8[DEBUG] " + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Info(string msg)
|
public override void Info(string msg)
|
||||||
{
|
{
|
||||||
if (InfoEnabled)
|
if (InfoEnabled)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@
|
||||||
void Debug(string msg, params object[] args);
|
void Debug(string msg, params object[] args);
|
||||||
void Debug(object msg);
|
void Debug(object msg);
|
||||||
|
|
||||||
|
void PacketDebug(string msg);
|
||||||
|
void PacketDebug(string msg, params object[] args);
|
||||||
|
void PacketDebug(object msg);
|
||||||
|
|
||||||
void Warn(string msg);
|
void Warn(string msg);
|
||||||
void Warn(string msg, params object[] args);
|
void Warn(string msg, params object[] args);
|
||||||
void Warn(object msg);
|
void Warn(object msg);
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,18 @@
|
||||||
Debug(msg.ToString() ?? string.Empty);
|
Debug(msg.ToString() ?? string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void PacketDebug(string msg);
|
||||||
|
|
||||||
|
public void PacketDebug(string msg, params object[] args)
|
||||||
|
{
|
||||||
|
PacketDebug(string.Format(msg, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PacketDebug(object msg)
|
||||||
|
{
|
||||||
|
PacketDebug(msg.ToString() ?? string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void Error(string msg);
|
public abstract void Error(string msg);
|
||||||
|
|
||||||
public void Error(string msg, params object[] args)
|
public void Error(string msg, params object[] args)
|
||||||
|
|
|
||||||
|
|
@ -795,7 +795,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
case PacketTypesIn.JoinGame:
|
case PacketTypesIn.JoinGame:
|
||||||
// Temporary fix
|
// Temporary fix
|
||||||
log.Debug("Receive JoinGame");
|
log.PacketDebug("Receive JoinGame");
|
||||||
|
|
||||||
receiveDeclareCommands = receivePlayerInfo = false;
|
receiveDeclareCommands = receivePlayerInfo = false;
|
||||||
|
|
||||||
|
|
@ -988,7 +988,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.DeclareCommands:
|
case PacketTypesIn.DeclareCommands:
|
||||||
if (protocolVersion >= MC_1_19_Version)
|
if (protocolVersion >= MC_1_19_Version)
|
||||||
{
|
{
|
||||||
log.Debug("Receive DeclareCommands");
|
log.PacketDebug("Receive DeclareCommands");
|
||||||
DeclareCommands.Read(dataTypes, packetData, protocolVersion);
|
DeclareCommands.Read(dataTypes, packetData, protocolVersion);
|
||||||
receiveDeclareCommands = true;
|
receiveDeclareCommands = true;
|
||||||
if (receivePlayerInfo)
|
if (receivePlayerInfo)
|
||||||
|
|
@ -2155,7 +2155,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
if (playerUuid == handler.GetUserUuid())
|
if (playerUuid == handler.GetUserUuid())
|
||||||
{
|
{
|
||||||
log.Debug($"Receive ChatUuid = {chatUuid}");
|
log.PacketDebug($"Receive ChatUuid = {chatUuid}");
|
||||||
this.chatUuid = chatUuid;
|
this.chatUuid = chatUuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2164,7 +2164,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
player.ClearPublicKey();
|
player.ClearPublicKey();
|
||||||
|
|
||||||
if (playerUuid == handler.GetUserUuid())
|
if (playerUuid == handler.GetUserUuid())
|
||||||
log.Debug("Receive ChatUuid = Empty");
|
log.PacketDebug("Receive ChatUuid = Empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerUuid == handler.GetUserUuid())
|
if (playerUuid == handler.GetUserUuid())
|
||||||
|
|
@ -4144,7 +4144,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (!log.DebugEnabled)
|
if (!log.DebugEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log.Debug(string.Format(Translations.debug_packet_state_change, previousState, newState));
|
log.PacketDebug(string.Format(Translations.debug_packet_state_change, previousState, newState));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LogIncomingPacket(int packetId, int payloadLength, int frameLength, bool compressed, int uncompressedLength)
|
private void LogIncomingPacket(int packetId, int payloadLength, int frameLength, bool compressed, int uncompressedLength)
|
||||||
|
|
@ -4159,7 +4159,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
? string.Format(Translations.debug_packet_compression_compressed, uncompressedLength)
|
? string.Format(Translations.debug_packet_compression_compressed, uncompressedLength)
|
||||||
: Translations.debug_packet_compression_uncompressed;
|
: Translations.debug_packet_compression_uncompressed;
|
||||||
|
|
||||||
log.Debug(string.Format(Translations.debug_packet_incoming,
|
log.PacketDebug(string.Format(Translations.debug_packet_incoming,
|
||||||
currentState,
|
currentState,
|
||||||
packetId,
|
packetId,
|
||||||
packetType,
|
packetType,
|
||||||
|
|
@ -4173,7 +4173,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (!log.DebugEnabled)
|
if (!log.DebugEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log.Debug(string.Format(Translations.debug_packet_outgoing,
|
log.PacketDebug(string.Format(Translations.debug_packet_outgoing,
|
||||||
currentState,
|
currentState,
|
||||||
packetId,
|
packetId,
|
||||||
packetType ?? ResolveOutgoingPacketType(packetId),
|
packetType ?? ResolveOutgoingPacketType(packetId),
|
||||||
|
|
@ -4186,7 +4186,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (!log.DebugEnabled)
|
if (!log.DebugEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log.Debug(string.Format(Translations.debug_packet_loop_exit,
|
log.PacketDebug(string.Format(Translations.debug_packet_loop_exit,
|
||||||
loopName,
|
loopName,
|
||||||
reason,
|
reason,
|
||||||
currentState,
|
currentState,
|
||||||
|
|
@ -4245,7 +4245,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
int nextState = isTransfer && protocolVersion >= MC_1_20_6_Version ? 3 : 2;
|
int nextState = isTransfer && protocolVersion >= MC_1_20_6_Version ? 3 : 2;
|
||||||
|
|
||||||
if (nextState == 3)
|
if (nextState == 3)
|
||||||
log.Debug("Using transfer handshake intent for transferred login.");
|
log.PacketDebug("Using transfer handshake intent for transferred login.");
|
||||||
|
|
||||||
// 1. Send the handshake packet
|
// 1. Send the handshake packet
|
||||||
SendPacket(0x00, dataTypes.ConcatBytes(
|
SendPacket(0x00, dataTypes.ConcatBytes(
|
||||||
|
|
@ -4389,7 +4389,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
var RSAService = CryptoHandler.DecodeRSAPublicKey(serverPublicKey)!;
|
var RSAService = CryptoHandler.DecodeRSAPublicKey(serverPublicKey)!;
|
||||||
var secretKey = CryptoHandler.ClientAESPrivateKey ?? CryptoHandler.GenerateAESPrivateKey();
|
var secretKey = CryptoHandler.ClientAESPrivateKey ?? CryptoHandler.GenerateAESPrivateKey();
|
||||||
|
|
||||||
log.Debug($"§8{Translations.debug_crypto}");
|
log.PacketDebug($"§8{Translations.debug_crypto}");
|
||||||
|
|
||||||
if (serverIDhash != "-" && !string.IsNullOrWhiteSpace(sessionID))
|
if (serverIDhash != "-" && !string.IsNullOrWhiteSpace(sessionID))
|
||||||
{
|
{
|
||||||
|
|
@ -4883,7 +4883,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
command = Regex.Replace(command, @"\s+", " ");
|
command = Regex.Replace(command, @"\s+", " ");
|
||||||
command = Regex.Replace(command, @"\s$", string.Empty);
|
command = Regex.Replace(command, @"\s$", string.Empty);
|
||||||
|
|
||||||
log.Debug($"chat command = {command}");
|
log.PacketDebug($"chat command = {command}");
|
||||||
|
|
||||||
if (protocolVersion >= MC_1_20_6_Version && !isOnlineMode)
|
if (protocolVersion >= MC_1_20_6_Version && !isOnlineMode)
|
||||||
{
|
{
|
||||||
|
|
@ -4911,7 +4911,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
needSigned = [];
|
needSigned = [];
|
||||||
log.Debug("DeclareCommands tree unavailable, sending command without signed arguments.");
|
log.PacketDebug("DeclareCommands tree unavailable, sending command without signed arguments.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6417,7 +6417,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
packet.AddRange(DataTypes.GetVarInt(playerKeyPair.PublicKey.SignatureV2!.Length));
|
packet.AddRange(DataTypes.GetVarInt(playerKeyPair.PublicKey.SignatureV2!.Length));
|
||||||
packet.AddRange(playerKeyPair.PublicKey.SignatureV2);
|
packet.AddRange(playerKeyPair.PublicKey.SignatureV2);
|
||||||
|
|
||||||
log.Debug(
|
log.PacketDebug(
|
||||||
$"SendPlayerSession MessageUUID = {chatUuid.ToString()}, len(PublicKey) = {playerKeyPair.PublicKey.Key.Length}, len(SignatureV2) = {playerKeyPair.PublicKey.SignatureV2!.Length}");
|
$"SendPlayerSession MessageUUID = {chatUuid.ToString()}, len(PublicKey) = {playerKeyPair.PublicKey.Key.Length}, len(SignatureV2) = {playerKeyPair.PublicKey.SignatureV2!.Length}");
|
||||||
|
|
||||||
SendPacket(PacketTypesOut.PlayerSession, packet);
|
SendPacket(PacketTypesOut.PlayerSession, packet);
|
||||||
|
|
|
||||||
|
|
@ -1532,6 +1532,15 @@ namespace MinecraftClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Show low-level packet debug logs..
|
||||||
|
/// </summary>
|
||||||
|
internal static string Logging_PacketDebugMessages {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Logging.PacketDebugMessages", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Show error messages..
|
/// Looks up a localized string similar to Show error messages..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -626,6 +626,9 @@ Want to upgrade to a newer version? See https://github.com/MCCTeam/Minecraft-Con
|
||||||
<data name="Logging.DebugMessages" xml:space="preserve">
|
<data name="Logging.DebugMessages" xml:space="preserve">
|
||||||
<value>Please enable this before submitting bug reports. Thanks!</value>
|
<value>Please enable this before submitting bug reports. Thanks!</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Logging.PacketDebugMessages" xml:space="preserve">
|
||||||
|
<value>Show low-level packet debug logs.</value>
|
||||||
|
</data>
|
||||||
<data name="Logging.ErrorMessages" xml:space="preserve">
|
<data name="Logging.ErrorMessages" xml:space="preserve">
|
||||||
<value>Show error messages.</value>
|
<value>Show error messages.</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
||||||
|
|
@ -1077,6 +1077,9 @@ namespace MinecraftClient
|
||||||
[TomlInlineComment("$Logging.DebugMessages$")]
|
[TomlInlineComment("$Logging.DebugMessages$")]
|
||||||
public bool DebugMessages = false;
|
public bool DebugMessages = false;
|
||||||
|
|
||||||
|
[TomlInlineComment("$Logging.PacketDebugMessages$")]
|
||||||
|
public bool PacketDebugMessages = false;
|
||||||
|
|
||||||
[TomlInlineComment("$Logging.ChatMessages$")]
|
[TomlInlineComment("$Logging.ChatMessages$")]
|
||||||
public bool ChatMessages = true;
|
public bool ChatMessages = true;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue