Fix bug in first-time RSA setup

This commit is contained in:
ME1312 2019-05-25 18:53:23 -04:00
parent 49036b8943
commit 08e3e202e3
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
3 changed files with 14 additions and 19 deletions

View File

@ -8,7 +8,6 @@ import java.security.Security;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.jar.Manifest;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
@ -87,9 +86,11 @@ public final class Launch {
System.out.println("SubServers.Bungee v" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':"")); System.out.println("SubServers.Bungee v" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println(""); System.out.println("");
} else { } else {
boolean gb; boolean gb = Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").getReturnType().equals(Class.forName("net.ME1312.Galaxi.Plugin.PluginInfo")), false);
if (!(gb = !Util.isException(() -> Util.reflect(net.md_5.bungee.log.LoggingOutputStream.class.getMethod("setLogger", Logger.class, String.class), null, if (gb) {
Util.reflect(net.md_5.bungee.log.BungeeLogger.class.getMethod("get", String.class), null, "SubServers"), "net.ME1312.SubServers.Bungee.")))) { Util.reflect(net.md_5.bungee.log.LoggingOutputStream.class.getMethod("setLogger", Logger.class, String.class), null,
Util.reflect(net.md_5.bungee.log.BungeeLogger.class.getMethod("get", String.class), null, "SubServers"), "net.ME1312.SubServers.Bungee.");
} else {
System.out.println(""); System.out.println("");
System.out.println("*******************************************"); System.out.println("*******************************************");
System.out.println("*** Warning: this build is unofficial ***"); System.out.println("*** Warning: this build is unofficial ***");
@ -126,14 +127,12 @@ public final class Launch {
plugin.start(); plugin.start();
if (!options.has("noconsole")) { if (!options.has("noconsole")) {
try { if (!gb) try {
if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands") != null, false)) { // Waterfall Setup if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands") != null, false)) { // Waterfall Setup
Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands").invoke(null); Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands").invoke(null);
} else if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("start") != null, false)) { } else if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("start") != null, false)) {
Class console = Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole"); Class console = Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole");
console.getMethod("start").invoke(console.getConstructor().newInstance()); console.getMethod("start").invoke(console.getConstructor().newInstance());
} else if (Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").invoke(null).getClass().getCanonicalName().equals("net.ME1312.Galaxi.Plugin.PluginInfo"), false)) {
// GalaxiBungee initializes its console automatically
} else { } else {
plugin.canSudo = true; plugin.canSudo = true;
String line; String line;

View File

@ -318,6 +318,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
} else if (ciphers[0].equals("RSA") || ciphers[0].equals("RSA-2048") || ciphers[0].equals("RSA-3072") || ciphers[0].equals("RSA-4096")) { } else if (ciphers[0].equals("RSA") || ciphers[0].equals("RSA-2048") || ciphers[0].equals("RSA-3072") || ciphers[0].equals("RSA-4096")) {
try { try {
int length = (ciphers[0].contains("-"))?Integer.parseInt(ciphers[0].split("-")[1]):2048; int length = (ciphers[0].contains("-"))?Integer.parseInt(ciphers[0].split("-")[1]):2048;
if (!(new UniversalFile("SubServers:Cache").exists())) new UniversalFile("SubServers:Cache").mkdirs();
subprotocol.registerCipher("RSA", new RSA(length, new UniversalFile("SubServers:Cache:private.rsa.key"), new UniversalFile("SubServers:subdata.rsa.key"))); subprotocol.registerCipher("RSA", new RSA(length, new UniversalFile("SubServers:Cache:private.rsa.key"), new UniversalFile("SubServers:subdata.rsa.key")));
cipher = "RSA" + cipher.substring(ciphers[0].length()); cipher = "RSA" + cipher.substring(ciphers[0].length());

View File

@ -1,12 +1,9 @@
package net.ME1312.SubServers.Sync; package net.ME1312.SubServers.Sync;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.Util; import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version; import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.Galaxi.Library.Version.VersionType;
import net.ME1312.SubServers.Sync.Library.Compatibility.GalaxiInfo; import net.ME1312.SubServers.Sync.Library.Compatibility.GalaxiInfo;
import java.lang.reflect.Field;
import java.security.Security; import java.security.Security;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
@ -24,7 +21,7 @@ public final class Launch {
* @param args Launch Arguments * @param args Launch Arguments
* @throws Exception * @throws Exception
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings({"deprecation", "unchecked"})
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("apple.laf.useScreenMenuBar", "true");
@ -89,9 +86,11 @@ public final class Launch {
System.out.println("SubServers.Sync v" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':"")); System.out.println("SubServers.Sync v" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println(""); System.out.println("");
} else { } else {
boolean gb; boolean gb = Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").getReturnType().equals(Class.forName("net.ME1312.Galaxi.Plugin.PluginInfo")), false);
if (!(gb = !Util.isException(() -> Util.reflect(net.md_5.bungee.log.LoggingOutputStream.class.getMethod("setLogger", Logger.class, String.class), null, if (gb) {
Util.reflect(net.md_5.bungee.log.BungeeLogger.class.getMethod("get", String.class), null, "SubServers"), "net.ME1312.SubServers.Sync.")))) { Util.reflect(net.md_5.bungee.log.LoggingOutputStream.class.getMethod("setLogger", Logger.class, String.class), null,
Util.reflect(net.md_5.bungee.log.BungeeLogger.class.getMethod("get", String.class), null, "SubServers"), "net.ME1312.SubServers.Sync.");
} else {
System.out.println(""); System.out.println("");
System.out.println("*******************************************"); System.out.println("*******************************************");
System.out.println("*** Warning: this build is Unofficial ***"); System.out.println("*** Warning: this build is Unofficial ***");
@ -120,8 +119,6 @@ public final class Launch {
System.out.println("*******************************************"); System.out.println("*******************************************");
} }
System.out.println(""); System.out.println("");
} else {
} }
SubPlugin plugin = new SubPlugin(System.out, patched); SubPlugin plugin = new SubPlugin(System.out, patched);
@ -130,14 +127,12 @@ public final class Launch {
plugin.start(); plugin.start();
if (!options.has("noconsole")) { if (!options.has("noconsole")) {
try { if (!gb) try {
if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands") != null, false)) { // Waterfall Setup if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands") != null, false)) { // Waterfall Setup
Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands").invoke(null); Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("readCommands").invoke(null);
} else if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("start") != null, false)) { } else if (Util.getDespiteException(() -> Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole").getMethod("start") != null, false)) {
Class console = Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole"); Class console = Class.forName("io.github.waterfallmc.waterfall.console.WaterfallConsole");
console.getMethod("start").invoke(console.getConstructor().newInstance()); console.getMethod("start").invoke(console.getConstructor().newInstance());
} else if (Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").invoke(null).getClass().getCanonicalName().equals("net.ME1312.Galaxi.Plugin.PluginInfo"), false)) {
// GalaxiBungee initializes its console automatically
} else { } else {
String line; String line;
while (plugin.isRunning && (line = plugin.getConsoleReader().readLine(">")) != null) { while (plugin.isRunning && (line = plugin.getConsoleReader().readLine(">")) != null) {