mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-03-25 00:07:31 +01:00
Always check for a key in Floodgate's folder first on plugin versions
This should avoid people trying to incorrectly copy the key.
This commit is contained in:
parent
f1098a9207
commit
7cd3eb99ef
4 changed files with 22 additions and 17 deletions
|
@ -45,6 +45,6 @@ public final class GeyserBungeeConfiguration extends GeyserJacksonConfiguration
|
||||||
Path geyserDataFolder = plugin.getDataFolder().toPath();
|
Path geyserDataFolder = plugin.getDataFolder().toPath();
|
||||||
Path floodgateDataFolder = floodgate != null ? floodgate.getDataFolder().toPath() : null;
|
Path floodgateDataFolder = floodgate != null ? floodgate.getDataFolder().toPath() : null;
|
||||||
|
|
||||||
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, floodgateDataFolder, geyserDataFolder, plugin.getGeyserLogger());
|
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgateDataFolder, geyserDataFolder, plugin.getGeyserLogger());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,6 @@ public final class GeyserSpigotConfiguration extends GeyserJacksonConfiguration
|
||||||
Path geyserDataFolder = plugin.getDataFolder().toPath();
|
Path geyserDataFolder = plugin.getDataFolder().toPath();
|
||||||
Path floodgateDataFolder = floodgate != null ? floodgate.getDataFolder().toPath() : null;
|
Path floodgateDataFolder = floodgate != null ? floodgate.getDataFolder().toPath() : null;
|
||||||
|
|
||||||
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, floodgateDataFolder, geyserDataFolder, plugin.getGeyserLogger());
|
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgateDataFolder, geyserDataFolder, plugin.getGeyserLogger());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
@ -44,7 +45,8 @@ public final class GeyserVelocityConfiguration extends GeyserJacksonConfiguratio
|
||||||
private Path floodgateKeyPath;
|
private Path floodgateKeyPath;
|
||||||
|
|
||||||
public void loadFloodgate(GeyserVelocityPlugin plugin, ProxyServer proxyServer, File dataFolder) {
|
public void loadFloodgate(GeyserVelocityPlugin plugin, ProxyServer proxyServer, File dataFolder) {
|
||||||
PluginContainer floodgate = proxyServer.getPluginManager().getPlugin("floodgate").orElse(null);
|
Optional<PluginContainer> floodgate = proxyServer.getPluginManager().getPlugin("floodgate");
|
||||||
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, Paths.get("plugins/floodgate/"), dataFolder.toPath(), plugin.getGeyserLogger());
|
Path floodgateDataPath = floodgate.isPresent() ? Paths.get("plugins/floodgate/") : null;
|
||||||
|
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgateDataPath, dataFolder.toPath(), plugin.getGeyserLogger());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,30 +33,33 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public class FloodgateKeyLoader {
|
public class FloodgateKeyLoader {
|
||||||
public static Path getKeyPath(GeyserJacksonConfiguration config, Object floodgate, Path floodgateDataFolder, Path geyserDataFolder, GeyserLogger logger) {
|
public static Path getKeyPath(GeyserJacksonConfiguration config, Path floodgateDataFolder, Path geyserDataFolder, GeyserLogger logger) {
|
||||||
if (config.getRemote().getAuthType() != AuthType.FLOODGATE) {
|
if (config.getRemote().getAuthType() != AuthType.FLOODGATE) {
|
||||||
return geyserDataFolder.resolve(config.getFloodgateKeyFile());
|
return geyserDataFolder.resolve(config.getFloodgateKeyFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
Path floodgateKey = geyserDataFolder.resolve(config.getFloodgateKeyFile());
|
// Always prioritize Floodgate's key, if it is installed.
|
||||||
|
// This mostly prevents people from trying to copy the key and corrupting it in the process
|
||||||
|
if (floodgateDataFolder != null) {
|
||||||
|
Path autoKey = floodgateDataFolder.resolve("key.pem");
|
||||||
|
if (Files.exists(autoKey)) {
|
||||||
|
logger.info(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.auto_loaded"));
|
||||||
|
return autoKey;
|
||||||
|
} else {
|
||||||
|
logger.error(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.missing_key"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Path floodgateKey;
|
||||||
if (config.getFloodgateKeyFile().equals("public-key.pem")) {
|
if (config.getFloodgateKeyFile().equals("public-key.pem")) {
|
||||||
logger.info("Floodgate 2.0 doesn't use a public/private key system anymore. We'll search for key.pem instead");
|
logger.info("Floodgate 2.0 doesn't use a public/private key system anymore. We'll search for key.pem instead");
|
||||||
floodgateKey = geyserDataFolder.resolve("key.pem");
|
floodgateKey = geyserDataFolder.resolve("key.pem");
|
||||||
|
} else {
|
||||||
|
floodgateKey = geyserDataFolder.resolve(config.getFloodgateKeyFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Files.exists(floodgateKey)) {
|
if (!Files.exists(floodgateKey)) {
|
||||||
if (floodgate != null) {
|
logger.error(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed"));
|
||||||
Path autoKey = floodgateDataFolder.resolve("key.pem");
|
|
||||||
if (Files.exists(autoKey)) {
|
|
||||||
logger.info(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.auto_loaded"));
|
|
||||||
floodgateKey = autoKey;
|
|
||||||
} else {
|
|
||||||
logger.error(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.missing_key"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.error(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return floodgateKey;
|
return floodgateKey;
|
||||||
|
|
Loading…
Add table
Reference in a new issue