From c2aa3352f0aec737bd1a8c265185ced204a87f17 Mon Sep 17 00:00:00 2001 From: Madis Otenurm Date: Wed, 16 Nov 2022 19:21:29 +0200 Subject: Add "insecure by whitelisting" state (#285) * Add insecure_whitelisted state * Update MixinChatScreen.java--- .../java/com/aizistral/nochatreports/core/ServerSafetyLevel.java | 8 ++++++++ .../aizistral/nochatreports/mixins/client/MixinChatScreen.java | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/com/aizistral/nochatreports/core/ServerSafetyLevel.java b/src/main/java/com/aizistral/nochatreports/core/ServerSafetyLevel.java index a12b10c..0808f4f 100644 --- a/src/main/java/com/aizistral/nochatreports/core/ServerSafetyLevel.java +++ b/src/main/java/com/aizistral/nochatreports/core/ServerSafetyLevel.java @@ -36,6 +36,14 @@ public enum ServerSafetyLevel { INSECURE, + /** + * Servers that don't require signatures but the user gave them anyway by whitelisting. + * The state is only displayed after the player toggles the whitelist for a server, because + * it is not possible to determine whether a server requires signatures if they are already given. + */ + + INSECURE_WHITELISTED, + /** * For Realms specifically, as these are a whole new level of unsafe. */ diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java index a77d81c..53b7149 100644 --- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java +++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java @@ -86,7 +86,9 @@ public abstract class MixinChatScreen extends Screen { if (ServerSafetyState.getCurrent() != ServerSafetyLevel.SECURE) { ServerSafetyState.setAllowChatSigning(true); - ServerSafetyState.updateCurrent(ServerSafetyLevel.INSECURE); + if(ServerSafetyState.getCurrent() != ServerSafetyLevel.INSECURE){ + ServerSafetyState.updateCurrent(ServerSafetyLevel.INSECURE_WHITELISTED); + } } } else { whitelist.remove(address); @@ -183,7 +185,7 @@ public abstract class MixinChatScreen extends Screen { return switch (level) { case SECURE -> 21; case UNINTRUSIVE -> 42; - case INSECURE -> 0; + case INSECURE, INSECURE_WHITELISTED -> 0; case REALMS -> 63; case UNKNOWN -> 84; case UNDEFINED -> 105; -- cgit v1.2.3