From 79661d17516db0e787d738dfe005a186873d6e70 Mon Sep 17 00:00:00 2001 From: Osiris Team Date: Tue, 7 May 2024 00:05:17 +0200 Subject: [PATCH] 8.0.1 - FIX: server-key invalid key not getting detected properly, thus causing retries --- pom.xml | 2 +- .../autoplug/client/configs/SystemConfig.java | 5 +++-- .../autoplug/client/network/online/ConMain.java | 13 ++++--------- .../client/network/online/DefaultConnection.java | 3 ++- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 1afca083..baca33e3 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ com.osiris.autoplug.client autoplug-client - 8.0.0 + 8.0.1 jar AutoPlug-Client diff --git a/src/main/java/com/osiris/autoplug/client/configs/SystemConfig.java b/src/main/java/com/osiris/autoplug/client/configs/SystemConfig.java index e2458124..a1c00053 100644 --- a/src/main/java/com/osiris/autoplug/client/configs/SystemConfig.java +++ b/src/main/java/com/osiris/autoplug/client/configs/SystemConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Osiris-Team. + * Copyright (c) 2021-2024 Osiris-Team. * All rights reserved. * * This software is copyrighted work, licensed under the terms @@ -52,7 +52,8 @@ public SystemConfig() throws IOException, DuplicateKeyException, YamlReaderExcep timestamp_last_backup = put(name, "timestamp-last-backup-task"); autoplug_web_ssl = put(name, "autoplug-web-ssl").setDefValues("true").setComments("If localhost is used below, remember to set this to false too!"); - autoplug_web_ip = put(name, "autoplug-web-ip").setDefValues("144.91.78.158").setComments("Set to localhost to test on the local server."); + autoplug_web_ip = put(name, "autoplug-web-ip").setDefValues("144.91.78.158").setComments("Set to localhost to test on the local server.", + "Otherwise set to 144.91.78.158 or autoplug.one to connect with the default production server (remember to enable autoplug-web-ssl in this case too)."); autoplug_web_port = put(name, "autoplug-web-port").setDefValues("35555"); autoplug_plugin_key = put(name, "autoplug-plugin-key"); diff --git a/src/main/java/com/osiris/autoplug/client/network/online/ConMain.java b/src/main/java/com/osiris/autoplug/client/network/online/ConMain.java index 14ccc87c..a3705c1a 100644 --- a/src/main/java/com/osiris/autoplug/client/network/online/ConMain.java +++ b/src/main/java/com/osiris/autoplug/client/network/online/ConMain.java @@ -8,11 +8,11 @@ package com.osiris.autoplug.client.network.online; -import com.osiris.autoplug.client.configs.GeneralConfig; import com.osiris.autoplug.client.network.online.connections.*; import com.osiris.jlib.logger.AL; import java.io.IOException; +import java.security.InvalidKeyException; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -54,14 +54,9 @@ public boolean open() { } catch (Exception e) { AL.warn(e); isDone = true; - try { - String key = new GeneralConfig().server_key.asString(); - if (key == null || key.isEmpty() || key.equals(NO_KEY)) - return false; - // else we continue below and retry the connection - } catch (Exception ex) { - return false; - } + if (e instanceof InvalidKeyException) + return false; // Abort directly since no valid key exists + // else we continue below and retry the connection } super.setAndStartAsync(() -> { try { diff --git a/src/main/java/com/osiris/autoplug/client/network/online/DefaultConnection.java b/src/main/java/com/osiris/autoplug/client/network/online/DefaultConnection.java index 32ebe7da..9df6d764 100644 --- a/src/main/java/com/osiris/autoplug/client/network/online/DefaultConnection.java +++ b/src/main/java/com/osiris/autoplug/client/network/online/DefaultConnection.java @@ -28,6 +28,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; +import java.security.InvalidKeyException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -118,7 +119,7 @@ private synchronized int _open() throws Exception { String serverKey = new GeneralConfig().server_key.asString(); if (serverKey == null || serverKey.equals("INSERT_KEY_HERE") || serverKey.equals(NO_KEY)) - throw new Exception("No valid key provided." + + throw new InvalidKeyException("No valid key provided." + " Register your server at " + GD.OFFICIAL_WEBSITE + ", get your server-key and add it to the /autoplug/general.yml config file." + " Enter '.con reload' to retry."); while (true) {