From 116efc5e781b345a3b34004e8b6d717a22c3c675 Mon Sep 17 00:00:00 2001 From: ORelio Date: Thu, 30 Apr 2020 17:37:57 +0200 Subject: [PATCH] Add additional error messages on login failures See #976 --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/ISSUE_TEMPLATE/general-question.md | 2 +- MinecraftClient/McTcpClient.cs | 7 ++++++- MinecraftClient/Protocol/Handlers/Protocol16.cs | 16 +++++++++++++--- MinecraftClient/Protocol/Handlers/Protocol18.cs | 6 ++++++ 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f8992c2d..a6a15a64 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -9,7 +9,7 @@ assignees: '' **Prerequisites** - [ ] I made sure I am running the latest [development build](https://ci.appveyor.com/project/ORelio/minecraft-console-client/build/artifacts) - - [ ] I tried to [look for similar issues](https://github.com/ORelio/Minecraft-Console-Client/issues?q=is%3Aissue) before opening an new one + - [ ] I tried to [look for similar issues](https://github.com/ORelio/Minecraft-Console-Client/issues?q=is%3Aissue) before opening a new one - [ ] I have set `debugmessages=true` in config to diagnose my issue - [ ] I have redacted session tokens and passwords before attaching screenshots diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index edaae94c..d3e33347 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -10,7 +10,7 @@ assignees: '' **Prerequisites** - [ ] I have read and understood the [user manual](https://github.com/ORelio/Minecraft-Console-Client/tree/master/MinecraftClient/config) - [ ] I made sure I am running the latest [development build](https://ci.appveyor.com/project/ORelio/minecraft-console-client/build/artifacts) - - [ ] I tried to [look for similar feature requests](https://github.com/ORelio/Minecraft-Console-Client/issues?q=is%3Aissue) before opening an new one + - [ ] I tried to [look for similar feature requests](https://github.com/ORelio/Minecraft-Console-Client/issues?q=is%3Aissue) before opening a new one **Feature description** A feature request should contain the following items: diff --git a/.github/ISSUE_TEMPLATE/general-question.md b/.github/ISSUE_TEMPLATE/general-question.md index 9ea759de..40cb760d 100644 --- a/.github/ISSUE_TEMPLATE/general-question.md +++ b/.github/ISSUE_TEMPLATE/general-question.md @@ -10,7 +10,7 @@ assignees: '' **Prerequisites** - [ ] I have read and understood the [user manual](https://github.com/ORelio/Minecraft-Console-Client/tree/master/MinecraftClient/config) - [ ] I made sure I am running the latest [development build](https://ci.appveyor.com/project/ORelio/minecraft-console-client/build/artifacts) - - [ ] I tried to [look for similar questions](https://github.com/ORelio/Minecraft-Console-Client/issues?q=is%3Aissue) before creating an new one + - [ ] I tried to [look for similar questions](https://github.com/ORelio/Minecraft-Console-Client/issues?q=is%3Aissue) before creating a new one **Description of the Questions** Your question may contain the following items: diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index e7b82812..6de3afd8 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -213,10 +213,15 @@ namespace MinecraftClient timeoutdetector.Start(); } } + else + { + Console.WriteLine("Failed to login to this server."); + retry = true; + } } catch (Exception e) { - ConsoleIO.WriteLineFormatted("§8" + e.Message); + ConsoleIO.WriteLineFormatted("§8" + e.GetType().Name + ": " + e.Message); Console.WriteLine("Failed to join this server."); retry = true; } diff --git a/MinecraftClient/Protocol/Handlers/Protocol16.cs b/MinecraftClient/Protocol/Handlers/Protocol16.cs index 43fbd6a1..58b2aa1f 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol16.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol16.cs @@ -470,7 +470,11 @@ namespace MinecraftClient.Protocol.Handlers return StartEncryption(uuid, username, sessionID, token, serverID, PublicServerkey); } - else return false; + else + { + ConsoleIO.WriteLineFormatted("§8Invalid response to Handshake packet"); + return false; + } } private bool StartEncryption(string uuid, string username, string sessionID, byte[] token, string serverIDhash, byte[] serverKey) @@ -486,6 +490,7 @@ namespace MinecraftClient.Protocol.Handlers Console.WriteLine("Checking Session..."); if (!ProtocolHandler.SessionCheck(uuid, sessionID, CryptoHandler.getServerHash(serverIDhash, serverKey, secretKey))) { + handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, "Failed to check session."); return false; } } @@ -520,7 +525,11 @@ namespace MinecraftClient.Protocol.Handlers encrypted = true; return true; } - else return false; + else + { + ConsoleIO.WriteLineFormatted("§8Invalid response to StartEncryption packet"); + return false; + } } public bool Login() @@ -555,9 +564,10 @@ namespace MinecraftClient.Protocol.Handlers } } } - catch + catch (Exception e) { //Connection failed + ConsoleIO.WriteLineFormatted("§8" + e.GetType().Name + ": " + e.Message); return false; } } diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index f3717f4f..fab2c9fc 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -863,7 +863,10 @@ namespace MinecraftClient.Protocol.Handlers login_phase = false; if (!pForge.CompleteForgeHandshake()) + { + ConsoleIO.WriteLineFormatted("§8Forge Login Handshake did not complete successfully"); return false; + } StartUpdating(); return true; //No need to check session or start encryption @@ -920,7 +923,10 @@ namespace MinecraftClient.Protocol.Handlers login_phase = false; if (!pForge.CompleteForgeHandshake()) + { + ConsoleIO.WriteLineFormatted("§8Forge StartEncryption Handshake did not complete successfully"); return false; + } StartUpdating(); return true;