Skip to content

Commit a6d0efe

Browse files
committed
Reduce ChatClient logging noise while keeping E2EE diagnostics
1 parent f2278b8 commit a6d0efe

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/main/java/garlicrot/rusherchat/ChatClient.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public ChatClient(String host, int port, java.util.function.Consumer<String> onR
9191
}
9292

9393
this.onReceive = onReceive;
94-
LOGGER.info("ChatClient instance created for " + serverUri);
94+
LOGGER.fine("ChatClient instance created for " + serverUri);
9595
initKeyPair();
9696
}
9797

@@ -104,7 +104,7 @@ private void initKeyPair() {
104104
this.keyPair = kpg.generateKeyPair();
105105
this.privateKey = keyPair.getPrivate();
106106
this.publicKey = keyPair.getPublic();
107-
LOGGER.info("Generated new RSA keypair for RusherChat");
107+
LOGGER.fine("Initialized RSA keypair for RusherChat E2EE");
108108
} catch (Exception e) {
109109
LOGGER.log(Level.SEVERE, "Failed to generate RSA keypair", e);
110110
}
@@ -212,7 +212,7 @@ private void handleUserKeySystemMessage(String content) {
212212
X509EncodedKeySpec spec = new X509EncodedKeySpec(decoded);
213213
PublicKey pk = KeyFactory.getInstance("RSA").generatePublic(spec);
214214
knownPublicKeys.put(username.toLowerCase(), pk);
215-
LOGGER.info("Stored public key for user " + username);
215+
LOGGER.fine("Stored public key for user " + username);
216216
} catch (Exception e) {
217217
LOGGER.log(Level.WARNING, "Failed to parse user public key for " + username, e);
218218
}
@@ -230,10 +230,16 @@ public void onOpen(ServerHandshake handshakedata) {
230230

231231
String username = Minecraft.getInstance().getUser().getName();
232232
Message login = new Message(Message.Type.LOGIN, username, null, null, null, false);
233+
234+
// Attach our public key without spamming logs
233235
String pubKeyB64 = getPublicKeyBase64();
234-
if (pubKeyB64 != null) {
236+
if (pubKeyB64 != null && !pubKeyB64.isEmpty()) {
235237
login.setPublicKey(pubKeyB64);
238+
LOGGER.fine("[E2EE] Attaching publicKey to LOGIN (length=" + pubKeyB64.length() + " chars)");
239+
} else {
240+
LOGGER.warning("[E2EE] Public key is null/empty at LOGIN time – not attaching key.");
236241
}
242+
237243
wsClient.send(gson.toJson(login));
238244

239245
if (SHOW_JOIN_MESSAGE) {
@@ -314,14 +320,14 @@ public void onError(Exception ex) {
314320
SSLContext sslContext = SSLContext.getInstance("TLS");
315321
sslContext.init(null, null, null);
316322
wsClient.setSocketFactory(sslContext.getSocketFactory());
317-
LOGGER.info("SSL context configured for WSS connection.");
323+
LOGGER.fine("SSL context configured for WSS connection.");
318324
} catch (Exception e) {
319325
LOGGER.log(Level.SEVERE, "Failed to set up SSL for WSS connection", e);
320326
}
321327
}
322328

323329
try {
324-
LOGGER.info("Attempting to connect to " + serverUri);
330+
LOGGER.fine("Attempting to connect to " + serverUri);
325331
wsClient.connectBlocking();
326332
} catch (InterruptedException e) {
327333
LOGGER.log(Level.SEVERE, "WebSocket connection failed", e);
@@ -496,7 +502,7 @@ public void close() {
496502
if (wsClient != null) {
497503
wsClient.close();
498504
wsClient = null;
499-
LOGGER.info("WebSocketClient closed.");
505+
LOGGER.fine("WebSocketClient closed.");
500506
}
501507
try {
502508
if (!scheduler.isShutdown()) {
@@ -559,4 +565,4 @@ private String formatDisplayMessage(Message msg, String content) {
559565
private String stripColor(String input) {
560566
return input.replaceAll("§[0-9A-FK-ORa-fk-or]", "").toLowerCase();
561567
}
562-
}
568+
}

0 commit comments

Comments
 (0)