From 35019699600e344526975345e08604cf486d53e2 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Thu, 9 Jun 2022 12:07:24 +0100 Subject: [PATCH] move force key checking into a system property (#736) --- .../main/java/com/velocitypowered/proxy/VelocityServer.java | 3 +++ .../proxy/connection/client/InitialLoginSessionHandler.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 783d100e5..c3272c85a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -315,6 +315,9 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { } commandManager.setAnnounceProxyCommands(configuration.isAnnounceProxyCommands()); + if (System.getProperty("auth.forceSecureProfiles") == null) { + System.setProperty("auth.forceSecureProfiles", String.valueOf(configuration.isForceKeyAuthentication())); + } } catch (Exception e) { logger.error("Unable to read/load/save your velocity.toml. The server will shut down.", e); LogManager.shutdown(); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java index eb3b1befa..3a4cae894 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialLoginSessionHandler.java @@ -68,12 +68,14 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler { private @MonotonicNonNull ServerLogin login; private byte[] verify = EMPTY_BYTE_ARRAY; private LoginState currentState = LoginState.LOGIN_PACKET_EXPECTED; + private boolean forceKeyAuthentication; InitialLoginSessionHandler(VelocityServer server, MinecraftConnection mcConnection, LoginInboundConnection inbound) { this.server = Preconditions.checkNotNull(server, "server"); this.mcConnection = Preconditions.checkNotNull(mcConnection, "mcConnection"); this.inbound = Preconditions.checkNotNull(inbound, "inbound"); + this.forceKeyAuthentication = Boolean.getBoolean("auth.forceSecureProfiles"); } @Override @@ -92,7 +94,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler { return true; } } else if (mcConnection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19) >= 0 - && server.getConfiguration().isForceKeyAuthentication()) { + && forceKeyAuthentication) { inbound.disconnect(Component.translatable("multiplayer.disconnect.missing_public_key")); return true; }