forked from GeyserMC/Geyser
* fix #1110 * updating comments in config.yml * Fix indentation * Centralize localhost retrieval; remove unnecessary Docker check * Add config.yml Co-authored-by: DoctorMacc <toy.fighter1@gmail.com>
This commit is contained in:
parent
1ead2900a3
commit
0e91475c62
8 changed files with 32 additions and 51 deletions
|
@ -81,17 +81,14 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||||
|
|
||||||
InetSocketAddress javaAddr = listener.getHost();
|
InetSocketAddress javaAddr = listener.getHost();
|
||||||
|
|
||||||
// Don't change the ip if its listening on all interfaces
|
// By default this should be localhost but may need to be changed in some circumstances
|
||||||
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||||
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
|
this.geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||||
this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
||||||
geyserConfig.getBedrock().setPort(javaAddr.getPort());
|
geyserConfig.getBedrock().setPort(javaAddr.getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.geyserConfig.getRemote().setPort(javaAddr.getPort());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
|
this.geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
|
||||||
|
|
|
@ -81,18 +81,15 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't change the ip if its listening on all interfaces
|
// By default this should be localhost but may need to be changed in some circumstances
|
||||||
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||||
if (!Bukkit.getIp().equals("0.0.0.0") && !Bukkit.getIp().equals("")) {
|
geyserConfig.getRemote().setPort(Bukkit.getPort());
|
||||||
geyserConfig.getRemote().setAddress(Bukkit.getIp());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
||||||
geyserConfig.getBedrock().setPort(Bukkit.getPort());
|
geyserConfig.getBedrock().setPort(Bukkit.getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
geyserConfig.getRemote().setPort(Bukkit.getPort());
|
|
||||||
|
|
||||||
this.geyserLogger = new GeyserSpigotLogger(getLogger(), geyserConfig.isDebugMode());
|
this.geyserLogger = new GeyserSpigotLogger(getLogger(), geyserConfig.isDebugMode());
|
||||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||||
|
|
||||||
|
|
|
@ -104,12 +104,10 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
||||||
|
|
||||||
// Don't change the ip if its listening on all interfaces
|
// Don't change the ip if its listening on all interfaces
|
||||||
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
||||||
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
|
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||||
serverIP.setValue("127.0.0.1");
|
|
||||||
}
|
|
||||||
|
|
||||||
serverPort.setValue(javaAddr.getPort());
|
serverPort.setValue(javaAddr.getPort());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ConfigurationNode bedrockPort = config.getNode("bedrock").getNode("port");
|
ConfigurationNode bedrockPort = config.getNode("bedrock").getNode("port");
|
||||||
if (geyserConfig.getBedrock().isCloneRemotePort()){
|
if (geyserConfig.getBedrock().isCloneRemotePort()){
|
||||||
|
|
|
@ -108,6 +108,9 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
||||||
try {
|
try {
|
||||||
File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
||||||
geyserConfig = FileUtils.loadConfig(configFile, GeyserStandaloneConfiguration.class);
|
geyserConfig = FileUtils.loadConfig(configFile, GeyserStandaloneConfiguration.class);
|
||||||
|
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||||
|
geyserConfig.getRemote().setAddress("127.0.0.1");
|
||||||
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.config.failed"), ex);
|
geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.config.failed"), ex);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
|
|
@ -92,18 +92,15 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
|
|
||||||
InetSocketAddress javaAddr = proxyServer.getBoundAddress();
|
InetSocketAddress javaAddr = proxyServer.getBoundAddress();
|
||||||
|
|
||||||
// Don't change the ip if its listening on all interfaces
|
// By default this should be localhost but may need to be changed in some circumstances
|
||||||
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||||
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
|
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||||
geyserConfig.getRemote().setAddress(javaAddr.getHostString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
||||||
geyserConfig.getBedrock().setPort(javaAddr.getPort());
|
geyserConfig.getBedrock().setPort(javaAddr.getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
|
||||||
|
|
||||||
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
||||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,14 @@ import org.geysermc.connector.network.translators.world.WorldManager;
|
||||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||||
import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
|
import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
|
||||||
import org.geysermc.connector.utils.DimensionUtils;
|
import org.geysermc.connector.utils.DimensionUtils;
|
||||||
import org.geysermc.connector.utils.DockerCheck;
|
|
||||||
import org.geysermc.connector.utils.LanguageUtils;
|
import org.geysermc.connector.utils.LanguageUtils;
|
||||||
import org.geysermc.connector.utils.LocaleUtils;
|
import org.geysermc.connector.utils.LocaleUtils;
|
||||||
|
|
||||||
import javax.naming.directory.Attribute;
|
import javax.naming.directory.Attribute;
|
||||||
import javax.naming.directory.InitialDirContext;
|
import javax.naming.directory.InitialDirContext;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -133,8 +134,16 @@ public class GeyserConnector {
|
||||||
SoundRegistry.init();
|
SoundRegistry.init();
|
||||||
SoundHandlerRegistry.init();
|
SoundHandlerRegistry.init();
|
||||||
|
|
||||||
if (platformType != PlatformType.STANDALONE) {
|
if (platformType != PlatformType.STANDALONE && config.getRemote().getAddress().equals("auto")) {
|
||||||
DockerCheck.check(bootstrap);
|
// Set the remote address to localhost since that is where we are always connecting
|
||||||
|
try {
|
||||||
|
config.getRemote().setAddress(InetAddress.getLocalHost().getHostAddress());
|
||||||
|
} catch (UnknownHostException ex) {
|
||||||
|
logger.debug("Unknown host when trying to find localhost.");
|
||||||
|
if (config.isDebugMode()) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String remoteAddress = config.getRemote().getAddress();
|
String remoteAddress = config.getRemote().getAddress();
|
||||||
int remotePort = config.getRemote().getPort();
|
int remotePort = config.getRemote().getPort();
|
||||||
|
|
|
@ -25,36 +25,13 @@
|
||||||
|
|
||||||
package org.geysermc.connector.utils;
|
package org.geysermc.connector.utils;
|
||||||
|
|
||||||
import org.geysermc.connector.bootstrap.GeyserBootstrap;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
public class DockerCheck {
|
public class DockerCheck {
|
||||||
public static void check(GeyserBootstrap bootstrap) {
|
|
||||||
try {
|
|
||||||
String OS = System.getProperty("os.name").toLowerCase();
|
|
||||||
String ipAddress = InetAddress.getLocalHost().getHostAddress();
|
|
||||||
|
|
||||||
// Check if the user is already using the recommended IP
|
|
||||||
if (ipAddress.equals(bootstrap.getGeyserConfig().getRemote().getAddress())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0) {
|
|
||||||
bootstrap.getGeyserLogger().debug("We are on a Unix system, checking for Docker...");
|
|
||||||
|
|
||||||
String output = new String(Files.readAllBytes(Paths.get("/proc/1/cgroup")));
|
|
||||||
|
|
||||||
if (output.contains("docker")) {
|
|
||||||
bootstrap.getGeyserLogger().warning(LanguageUtils.getLocaleStringLog("geyser.bootstrap.docker_warn.line1"));
|
|
||||||
bootstrap.getGeyserLogger().warning(LanguageUtils.getLocaleStringLog("geyser.bootstrap.docker_warn.line2", ipAddress));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) { } // Ignore any errors, inc ip failed to fetch, process could not run or access denied
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// By default, Geyser now sets the IP to the local IP in all cases on plugin versions so we don't notify the user of anything
|
||||||
|
// However we still have this check for the potential future bug
|
||||||
public static boolean checkBasic() {
|
public static boolean checkBasic() {
|
||||||
try {
|
try {
|
||||||
String OS = System.getProperty("os.name").toLowerCase();
|
String OS = System.getProperty("os.name").toLowerCase();
|
||||||
|
|
|
@ -22,8 +22,11 @@ bedrock:
|
||||||
motd2: "Another GeyserMC forced host."
|
motd2: "Another GeyserMC forced host."
|
||||||
remote:
|
remote:
|
||||||
# The IP address of the remote (Java Edition) server
|
# The IP address of the remote (Java Edition) server
|
||||||
address: 127.0.0.1
|
# If it is "auto", for standalone version the remote address will be set to 127.0.0.1,
|
||||||
|
# for plugin versions, Geyser will attempt to find the best address to connect to.
|
||||||
|
address: auto
|
||||||
# The port of the remote (Java Edition) server
|
# The port of the remote (Java Edition) server
|
||||||
|
# For plugin versions, if address has been set to "auto", the port will also follow the server's listening port.
|
||||||
port: 25565
|
port: 25565
|
||||||
# Authentication type. Can be offline, online, or floodgate (see https://github.com/GeyserMC/Geyser/wiki/Floodgate).
|
# Authentication type. Can be offline, online, or floodgate (see https://github.com/GeyserMC/Geyser/wiki/Floodgate).
|
||||||
auth-type: online
|
auth-type: online
|
||||||
|
|
Loading…
Reference in a new issue